LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-17-2007, 01:27 PM   #1
talat
Member
 
Registered: Jan 2006
Distribution: Centos
Posts: 145

Rep: Reputation: 16
Question Sql query issue


Hi Guys

I have a table which has two columns

Code:
mysql> desc email;
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| mail | varchar(255) | YES | | NULL | |
| pass | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

mysql>

Now i have a file from which i fill data in this table.The structure of file was like this

emailidpass\n

e.g

talat@xyz.comtalat123\n
shane@xyz.comshane\n

I seperated the email id and password with the following sed command.

Code:
sed 's/xyz.com/xyz.com\t/g' file > newfile
Then i load this file data in my table with following cmd.
Code:
mysql> load data local infile '/home/talat/newfile' into table email;

Now when i see the data via simple select cmd then it showes me like this.

| basham@xyz.com | 0512879595
|
| shakil.anwar@xyz.com | anwar
|
| pyramids@xyz.com | chasim
|
| tariq@xyz.com | 554321
|
| info@xyz.com | 1234
|
| palls@xyz.com | sllap


Now the problem is this .When i try to select any particular line with WHERE clause then it does not show me result.

Code:
mysql> select mail from email where pass= 'anwar';
Empty set (0.06 sec
)

I am unable to understand why this is happening. Plz guide.I have another table in this DB and the the select query is working fine on that table.

Regard
Talat
 
Old 10-17-2007, 02:24 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
If that select output is correct, it looks like the \n after the password may have been included in the password field. (No idea why that might be true -- I haven't use mysql for several years now.)

Instead of pass= in your query, try a pass like query and see what you get.
 
Old 10-18-2007, 06:34 AM   #3
talat
Member
 
Registered: Jan 2006
Distribution: Centos
Posts: 145

Original Poster
Rep: Reputation: 16
Hi PTrenholme

Its also not working.

Code:
mysql> select * from email where pass like 'anwar';
Empty set (0.06 sec)
Regard
Talat
 
Old 10-18-2007, 08:59 AM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Hum. Try LIKE '%anwar%' If that works, try it without the wild-card at the front or the end. (Some SQLs treat 'LIKE anwar' as if it were a regexp, others as if the 'LIKE' was an '='. I'm not sure about mysql, so I'm suggesting using explicit wild-cards.)

Oh, looking at pinfo mysgl, under function->string->comparisons, I notice that mysql offers a 'REGEXP' and 'RLIKE' comparison operator in addition to a simple 'LIKE'. Perhaps a REGEXP might work better.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in SQL Query.. gobi_dgm Linux - Software 1 02-03-2007 09:41 AM
SQL query question Kamikazee Programming 2 10-31-2006 10:27 AM
Query SQL error gabsik Linux - Software 37 07-22-2006 02:34 AM
Massive SQL Query patpawlowski Programming 7 03-05-2004 04:24 PM
SQL Query question oulevon Programming 7 01-16-2004 01:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration