Pastebin

Paste #1484: mysql subselect

< previous paste - next paste>

Pasted by tdn

Download View as text

SELECT foo 
FROM bar 
WHERE foobar IN ( SELECT name FROM person )



'-------------------
SELECT foo 
FROM bar 
WHERE foobar IN (''+ SELECT name FROM person +'')


'-------------------
SELECT foo 
FROM bar 
WHERE foobar IN ('lars','peter','jørgen')





select * from smsbox_outbox_sonofon.smsbox_outbox_new A
WHERE A.service_Fkey='1002401'
AND A.message_key like '%20100210%'
AND A.MOBILE in(

  SELECT DISTINCT LEFT(B.message_Key, 10) AS mo_MSISDN
  FROM smsbox_outbox_sonofon.smsbox_message_retry B
  where
  B.message_key like '%20100210%' AND
  B.error_message='Message not send'
  OR
  B.message_key like '%20100210%' AND
  B.error_message='Message not send'
  /*GROUP BY B.message_Key*/
  having count(B.message_key) >2
  limit 1
)



-----------------
You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT DISTINCT LEFT(B.message_Key, 10) AS mo_MSISDN
  FROM sm

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.