tags:

views:

244

answers:

1
+2  A: 
INSERT INTO aatest
SELECT IF(COUNT(a2.letter)=0,'a','xa')
FROM aatest a1
LEFT JOIN aatest a2 ON a1.letter = a2.letter OR a2.letter IS NULL
WHERE a2.letter = 'a'

Will literally do what you asked...but it's not a proper solution unless you have a very unique issue you're trying to solve. It will fail if 'a' comes up again in the list because 'xa' will already be there too. A two query solution would be much easier to do assuming you're executing this within PHP or something.

Hope this helps...if you provide more details I may be able to be more helpful.

Jack