I am trying to select the following query from my table:
SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME,
date_format(str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), '%d %m %Y' ) AS shortDate
FROM AUCTIONS WHERE SUBCAT = 'fake' and USERNAME = 'testuser' ORDER BY
str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), article_no limit 0, 10
I get 0 results back.
However, both
SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME,
date_format(str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), '%d %m %Y' ) AS shortDate
FROM AUCTIONS WHERE SUBCAT = 'fake' ORDER BY
str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), article_no limit 0, 10
and
SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME,
date_format(str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), '%d %m %Y' ) AS shortDate
FROM AUCTIONS WHERE USERNAME = 'testuser' ORDER BY
str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), article_no limit 0, 10
return the expected result sets. Why are they not working together?
WHERE SUBCAT = ‘fake’ and USERNAME = ‘testuser’
Should be:
WHERE SUBCAT = ‘fake’ OR USERNAME = ‘testuser’
this will return both results which is what you’re after right?
Edit:
Sorry, misread the fields. Add the “SUBCAT” column into your queries so you can see how many occurences there are with each one and make sure the combination will produce results before applying both where clauses.