I'm new to SQL, and I'm trying to figure out how to construct a query where it will select values that contain a string "X" and then look for values that contain a string "Y" if X does not exist.
Here is my sample code:
SELECT RB_MLS_1.CATEGORYID,
RB_MLS_1.CATEGORYNAME, RB_MLS_1.COST,
RB_MLS_1.COSTTYPEID,
RB_MLS_1.COSTTYPENAME,
RB_MLS_1.DESCRIPTION, RB_MLS_1.DOWNLOADID,
RB_MLS_1.ID, RB_MLS_1.MEDIADESCRIPTION,
RB_MLS_1.MEDIAID, RB_MLS_1.NAME,
RB_MLS_1.QUANTITY,
RB_MEDIA_1.DESCRIPTION DESCRIPTION_2,
RB_MEDIA_1.ID ID_2
FROM RB_MLS RB_MLS_1
LEFT OUTER JOIN RB_MEDIA RB_MEDIA_1 ON
(RB_MEDIA_1.ID = RB_MLS_1.MEDIAID)
WHERE ( RB_MLS_1.CATEGORYNAME IN ('B&W Display') )
AND ( RB_MEDIA_1.CATEGORYNAME IN ('Daily','Weekly') )
AND (( RB_MLS_1.NAME LIKE '2 col x 7%')
OR (SELECT RB_MLS_1.NAME Like '1/4%'))
The result of my query is that I am getting all RB_MLS_1.NAME records that contain '2 col x 7' and '1/4'. Does anyone know how I can select LIKE '2 col x 7%' first and then select LIKE '1/4%' if '2 col x 7%' does not exist? Thanks for your help in advance.