Problems with MySQL OR clause
- by Simon
I have a problem with AND and OR clause in SQL. Here is my query:
SELECT
`act1`.`name`,
`act1`.`surname`,
`act2`.`name`,
`act2`.`surname`,
`act3`.`name`,
`act3`.`surname`
FROM
`videos`,
`actors` AS act1,
`actors` AS act2,
`actors` AS act3
WHERE
`videos`.`ident` = 'somethink'
AND
(
`act1`.`id` = `videos`.`id_actor1`
OR
`act2`.`id` = `videos`.`id_actor2`
OR
`act3`.`id` = `videos`.`id_actor3`
)
It returns me all variations of {name, surname}, but I want the name and surname of first exactly, second and thirth, if they exist.