No Result Returned From SQL Query
I am running the following query, but no rows are 开发者_Python百科returned even though a record exists that should match the query.
SELECT
*
FROM
tblsignup
WHERE
usr_email='amir@gmail.com'
AND
(status=1 or status=2)
You should try by simplifying the query (yeah...even if it's so simple)
try this
Select * from tblsignup
then
Select * from tblsignup where usr_email = 'amir@gmail.com'
then
Select * from
tblsignup
whereusr_email
='amir@gmail.com' and status > 0
//I know you won't use > 0 at the end, but we want to eliminate the most cause of error we simplify by > 0 only to be easier to read
Tell us from where you start getting 0 line, this could lead us to the problem, I know I already had a problem like that with a field named "date", because date is already used by MySQL, funny MySQL still let me use that fieldname tho.
Try this:
select * from `tblsignup` where `usr_email`='amir@gmail.com' and (`status`=1 or `status`=2)
I have a feeling "status" might be reserved for something special. It might be worth a shot changing it to `status`.
Try wrapping brackets around the status
column name:
SELECT *
FROM tblsignup
WHERE usr_email = 'amir@gmail.com'
AND ([status] = 1
OR [status] = 2);
EDIT After reading your comment, why not use:
SELECT *
FROM tblsignup
WHERE usr_email = 'amir@gmail.com'
AND [status] > 0;
May it be that your column or table has case sensitive collation and the address is typed different ('Amir...')? As your query is correct SQL. You can find that with:
EXEC sp_help DatabaseName
精彩评论