table - MySQL Statement without a JOIN -


i have mysql table trying query articles_data , don't want joins other tables.

it has rows:

article_id  doc_type  doc_type_id 1           1         2 1           2         1 2           1         2 3           1         2 3           2         1 

i trying write query return doc_type 1 , doc_type_id 2 , has row same article_id doc_type 2 , doc_type_id 1 in above example trying return article_id 1 , 3.

any ideas how would write sql query this?

you don't have join other tables, self join

this top of head, might need tweak syntax

select distinct article_id articles_data join articles_data b on b.articles_id = a.articles_id a.doc_type = 1 , a.doc_type_id = 2 , b.doc_type = 2 , b.doc_type_id = 1 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -