i have 2 simple querys, need little join them in 1 result
$query="select * usluge marka='1'";
and second query
$query2="select * usluge marka='2'";
i know result $query give table usluge marka=1, , result $query2 give me table usluge wwhere marka=2
but need join 2 querys in 1 query, , when while loop, give me result both querys, not 2 different while loops, 1 while loops results both querys?
is possible, example gave simple query understand :)
as long table structure same (more specifically, if both queries return same number of fields , same datatypes), can use sql union
keyword, example:
select id, name table1 union select id, name table2
note though if number of returned columns or datatypes not match, attempting execute query result in error, example,
select id, name, comment table1 union select id, name table2
will not work , result in error.
edit: rewritten question, using or
or in
in where
clause better solution:
select * usluge marka='1' or marka='2'
or
select * usluge marka in ('1', '2');
Comments
Post a Comment