Click here to Skip to main content
15,906,569 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, I am doing a little project using mysql to manage feeds from sites and show them to the registered users, style Google Reader, to backend I am using GO and DBMS MySQL, everything went smoothly until the moment I 'd write a query to compare email addresses, I introduced an email query, style something like this:

SELECT id FROM User WHERE Email = "tu@dominio.com"

described above query returns me null, a user exists in the table with this mail, but when I do the same query comparing other fields such as name, user puts me correctly, someone has idea that may be happening here ?, greetings and Thanks ...
Posted
Comments
CHill60 12-Feb-15 12:07pm    
If you run
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
is ANSI_QUOTES listed (i.e. enabled)?

Two problems:
1) User is an SQL Keyword, so using it for the name of your table is a little silly...
2) Don't use double quotes for a string, use single quotes with SQL.
Try this:
SQL
SELECT id FROM [User] WHERE Email = 'tu@dominio.com'


[edit]Typos... :sigh: [/edit]
 
Share this answer
 
v2
Comments
Cesar Bretana Gonzalez 12-Feb-15 12:35pm    
yeah, but I'm using MySQL, so I'm referencing to my fields like this:

SELECT id FROM test.User WHERE test.User.mail = 'your@domain.com', would be something with the at(@) symbol?
One possibility is that you have a mismatch in upper/lower characters. Try something like
SQL
SELECT id FROM User WHERE lower(Email) = "tu@dominio.com"
 
Share this answer
 
Comments
Maciej Los 12-Feb-15 13:32pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900