4 posts in this topic

Posted (edited)

Something like this,

WHERE (/* LIST OF STUFF PASSED IN */) ARE IN (/* QUERY */)

Well actually one will be a list of things I pass in.

 

EDIT: Apparently you cannot union of list of params eg UNION ('a', 'b', 'c')

EDIT 2: Apparently a comma separated list of stuff is not the same as a query of one column :|

Edited by _Alexander

Share this post


Link to post
Share on other sites

Posted

Something like this,

WHERE (/* QUERY 1 */) ARE IN (/* QUERY 2 */)

Well actually one will be a list of things I pass in.

 

EDIT: Apparently you cannot union of list of params eg UNION ('a', 'b', 'c')

If you save each query as a view and then do a union, you should be able to do what you are trying.

Share this post


Link to post
Share on other sites

Posted

Actually the outer query is to get an article id

WHERE (list of tags passed in as parameters) are in (query to get all tags on that specific article)

 

I think I can do it with count but it is visually messy.

Share this post


Link to post
Share on other sites

Posted

Hi,

 

This is a really simple one, you use the IN clause...

SELECT *
FROM tblMain
WHERE mainId IN
(
    SELECT subId
    FROM tblSub
)

More info: http://www.tutorialspoint.com/mysql/mysql-in-clause.htm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.