My PHP and MySQL query returns wrong information.
for the purpose of this Query - $PortalAdvertiserOne and $PortalAdvertiserTwo is INT
$sql = "
SELECT *
FROM
( SELECT *
FROM 100_advertisers_campaigns
WHERE vendor_owner IN($PortalAdvertiserOne,$PortalAdvertiserTwo)
AND ad_section_news = 'Y'
AND ad_position = 2
ORDER
BY RAND()
LIMIT 1
) x
ORDER
BY ad_id";
The Query returns everything perfect except where "ad_position" is supposed to return only records with 2, this query returns records from my table with 1, 2, 3 and 4. It does not seem to filter that part of the query.
What am i missing ?
尝试用()将或四舍五入
$sql = "SELECT * FROM (SELECT * FROM 100_advertisers_campaigns WHERE (vendor_owner = $PortalAdvertiserOne or vendor_owner = $PortalAdvertiserTwo and ad_section_news = 'Y') and ad_position = '2' ORDER BY RAND() LIMIT 1) x ORDER BY ad_id";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.