Hi hope someone can help me with the following

$query3 ="SELECT * FROM narr_turnier_bambini_garde UNION SELECT * FROM narr_turnier_bambini_garde_ster WHERE id_turnier_jaar = ".$idturnierjaar." order by rang, meestepunten DESC";

The WHERE clause dosn't work what i want
because it give me all the rows from both tables and column id_turnier_jaar is an id number and it is more then ones it could be shall we say 5 times with an id number 1 and some where else is the id numer about 7 times with the id number 2.

$idturnierjaar is the id number from POST from a form.

Thanks in advice JOHN

Member Avatar for LastMitch

@johnnyd1963

The WHERE clause dosn't work what i want
because it give me all the rows from both tables and column id_turnier_jaar is an id number and it is more then ones it could be shall we say 5 times with an id number 1 and some where else is the id numer about 7 times with the id number 2.

Can explain a little more about the 5 and 7 times. It wasn't very clear.

But you can try this:

$query3 ="(SELECT * FROM narr_turnier_bambini_garde WHERE id_turnier_jaar = ".$idturnierjaar." >= 5) UNION (SELECT * FROM narr_turnier_bambini_garde_ster WHERE id_turnier_jaar = ".$idturnierjaar." = 7) ORDER BY rang, meestepunten DESC";

OKE BUT i saw now what i dit wrong

i pease of your code was right

= 5 and = 7 i take it both away
it must be

$query3 ="SELECT * FROM narr_turnier_junioren_schautanz  WHERE id_turnier_jaar = ".$idturnierjaar." UNION SELECT * FROM narr_turnier_junioren_schautanz_ster  WHERE turnier_jaar=".$_POST['turnierjaarversturen']." order by rang, meestepunten DESC";

Thanks for your help it works perfect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.