SELECT * FROM book WHERE (label LIKE '%BB%') AND site='BKK' AND dateAdd='2014-08-07'
UNION SELECT * FROM book WHERE (label LIKE '%AA%') AND site='BKK' AND dateAdd='2014-08-07'
UNION SELECT * FROM book WHERE (label LIKE '%BB%') AND site='BKK' AND dateAdd='2014-08-07'
UNION SELECT * FROM book WHERE (label LIKE '%CC%') AND site='BKK' AND dateAdd='2014-08-07'
UNION SELECT * FROM book WHERE (label LIKE '%DD%') AND site='BKK' AND dateAdd='2014-08-07'
UNION SELECT * FROM book WHERE (label LIKE '%EE%') AND site='BKK' AND dateAdd='2014-08-07'
SELECT * FROM book WHERE site='BKK' AND dateAdd='2014-08-07'
AND label regexp '(AA|BB|CC|DD|EE)'
MSSQL Code (SQL)
SELECT * FROM book WHERE site='BKK' AND dateAdd='2014-08-07'
AND ( label like '%AA%' or label like '%BB%' or label like '%CC%' or label like '%DD%' or label like '%EE%' )
select * from
(
select 'AA%' as dynPattern
union all
select 'BB%'
union all
select 'CC%'
union all
select 'DD%'
) as tmp
Inner join book as b on b.label like tmp.dynPattern
and b.site = 'BKK' and b.dateAdd = '2014-08-07'
ข้อสงสัยที่มีประโยชน์ (ถ้าคุณมองเห็น)
Code (SQL)
select * from
(
select 'AA%' as dynPattern
union all
select 'BB%'
union all
select 'CC%'
union all
select 'DD%'
) as tmp
Inner join book as b on b.label like tmp.dynPattern
Where b.site = 'BKK' and b.dateAdd = '2014-08-07'