Thanks, that worked for song named "Empire", however, when I checked other song names such as songname called "One" I get two results:
| id | songname | +----+------------------------+ | 35 | You're Still The One | | 57 | One | +----+------------------------+ 2 rows in set (0.00 sec) How do I get exact match only between two strings or remove whitespace before and after string? I can't seem to find any good emaples of string comparisons for exact match. Songname field is a VARCHAR(55). I thought VARCHAR saves only the length of the string where as CHAR adds whitespace to parts not used in the field > "Like" is better because maybe there is a \n or \r\n after your string, > further it seems there are many whitespaces after the word. > Try WHERE songname LIKE "%Empire%". > > just my 0,02 > > jan > > > ----- Original Message ----- > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > Sent: Sunday, June 23, 2002 2:27 PM > Subject: Strings query question > > > I do not understand string comparison. Why doesn't the > following work: > > SELECT id, songname FROM songs WHERE songname = "Empire"; > > All I get is: Empty set (0.00 sec) > > I know the string exists in the database: > > In record 135 exists: > Empire | > | 135 | > > Do I have to use "LIKE"? > > I want to match a string from one table with a string > from another table so I can display the data from the > matched record. > > select movietable.id, movietable.songname, songs.id, > songs.songname FROM movietable, songs WHERE > movietable.songname = songs.songname; > > Results: Empty set (0.19 sec) > > This doesn't work either > select movietable.songname, movietable.ID, > songs.songname, songs.id FROM movietable, songs WHERE > movietable.songname = "Empire"; > > Yet, I know that movietable.songname contains a song > called "Empire" and movietable.songs also contains a > song called "Empire" > > How do I match the two strings? > > Running Linux with MySQL-3.23.32-1.7 > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php