0

This is my query

select PhoneNumber as _data,PhoneType as _type from contact_phonenumbers where ContactID = 3 and Type = 'R' and PT = 'M' 
union 
SELECT EmailID,Type  from contact_emails where ContactID = 3 and Type = 'P' 
UNION
SELECT EmailID,Type from contact_emails where ContactID = 3 and Type = 'O' 

Here my problem is i need to fetch only one row from each select statement. Is it possible to fetch it through "limit".

0

1 Answer 1

5

According to MySQL website you can apply limit to an individual select like that

(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)
UNION
(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);

http://dev.mysql.com/doc/refman/5.0/en/union.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.