View Full Version : Mysql - Email as a Secondry Key
doog
March 10th, 2005, 09:40 PM
I am using a user's email address as a primary key. And so, email address is a secondry key in another table. When I use the email address in the primary table, mysql returns results. When I say where email = 'asdf@asdf.com' in the secondary table I get no results. Any clue? Also, is an email address a good primary and secondary key. By secondary key I mean foriegn key.
z1p
March 10th, 2005, 10:37 PM
Are there records in the second table with the email address you use in the query? On the surface it seems like the query should work.
doog
March 11th, 2005, 03:56 PM
Yes, there are records in the secondary table. Good question though, I checked this out before posting. I think there is an issue using . or @ simbols. I can write "Select * from table where email like '%asdf%'" and it retreives the two records containing asdf@asdf.com as the email. When I try '%asdf@%' or '%asdf.%' I get the empty set.
Steven.Bentley
March 13th, 2005, 04:51 PM
are you using like rather than = with your wildcard % characters? eg where email like "asdf@asdf.com" rather than email = "asdf@asdf.com"?
z1p
March 15th, 2005, 07:37 PM
doog, Have you had any luck? Have you tried escaping the @ or try like '*asdf@*'. I know the last isn't the most desirable since it is specific to mysql, but any port in a storm. ;)