I need to find the correct syntax for this php mysql query and despite searching and trial and error, I've drawn a blank.
I have a table of stockists - 'Stockists' and I need to pull the data from each row depending on the presence of state1, state2 or both. If only state1 is present then pull that record, if they're both present then I need the record based on state2
SELECT * FROM Stockists WHERE state1 = 'vic' AND state2 IS NULL IF state2 IS NOT NULL THEN SELECT * FROM Stockists WHERE state2 = 'vic'
I've searched and played with quite a few different examples but nothing seems to work. Any advice or leads would be most appreciated.
Cheers
Aucun commentaire:
Enregistrer un commentaire