mysql - Most efficient/succinct way of combining queries with a filter? -
query #1:
select destination_content.content, destination_content.state destination_content
gives me
state content az lorem az ipsum az dolor nc sit ny blabla
query #2:
select properties.state, properties.name properties properties.active = 1
gives me
state content az ritz carlton az hotel malala ny gilt ny
i want combine query #1 query #2 that:
i results of query #1 it's filtered result for
nc sit
will not show up.
end result should be:
state content az lorem az ipsum az dolor ny blabla
does not show up, because there no active property in north carolina. want filter active property states.
what's succinct way of combining these queries?
edit: maybe brain isn't working atm tried inner join properties on ( destination_content.state = properties.state )
gives me more rows results need. 230 because there 230 content pieces, becomes around 1000 after join. did forget?
you should join tables:
select dc.content, dc.state destination_content dc inner join properties p on ( dc.state = p.state , dc.content = p.content ) p.active = 1
it should easier btw join tables if you'd have primary key (id) in each table.
Comments
Post a Comment