|
|
|
|
|
|
|
![]() |
#1 |
Vagabond
|
I think I might've solved it.
UNION ! Why have I never used that before? ![]() |
![]() |
![]() |
![]() |
#2 |
Wheither you think you can or you think you can't, Your right.
|
SELECT count
FROM table WHERE keyword = 'horizontal' AND keyword = 'vertical' AND (keyword = 'small' OR keyword = 'button') That is to find only sponsors that have horz and vert and butt/small baners. It must match all three conditions to be a match. Is that what you are looking for? Not sure why your using UNION, that is usually for selecting from different tables, if I remember right. Also LIKE is use more for a wildcard type select with % as the wild card. ronnie |
![]() |
![]() |
![]() |
#3 | |
Vagabond
|
Quote:
![]() If I would have 3 keyword fields: keyword1, keyword2, keyword3 then I could do it that way. And LIKE is just an old habit I have since the Sybase days. Mysql isn't as picky when it comes to =/LIKE, if you just put it in quotes it will treat it as a string. But for standard SQL, LIKE is for strings and = is for numerics. |
|
![]() |
![]() |
![]() |
#4 |
Wheither you think you can or you think you can't, Your right.
|
Thought you were trying to match rows, not tables, that would help..
![]() As for LIKE, guess I am old school, proper coding so I dont run in to trouble later. ronnie |
![]() |
![]() |
![]() |
#5 | |
Vagabond
|
Quote:
![]() I have it pretty much figured out, but it's in 2 queries. #1. Get all sponsors #2. Check if sponsor has the type of banners I'm looking for SELECT 3 = COUNT(*) FROM ( SELECT DISTINCT 1 FROM banners WHERE sponsor LIKE 'sponsor1' AND keyword LIKE 'horizontal' UNION ALL SELECT DISTINCT 1 FROM banners WHERE sponsor LIKE 'sponsor1' AND keyword LIKE 'vertical' UNION ALL SELECT DISTINCT 1 FROM banners WHERE sponsor LIKE 'sponsor1' AND (keyword LIKE 'small' OR keyword LIKE 'button') ) AS tbl 3 is how many different banners I'm looking for. I just wish I could get rid of step #1 and just make it into one query. |
|
![]() |
![]() |
![]() |
|
|