The function
sql_in_select()
returns a
sql_in
from the result of a
sql_select
.
It accepts the same arguments as
sql_select
plus one additional parameter in first place:
-#
$in
is the name of the column on which the
IN
will be applied,
-#
$select
,
-#
$from
,
-#
$where
,
-#
$groupby
,
-#
$orderby
,
-#
$limit
,
-#
$having
,
-#
$serveur
,
-#
$option
.
You can use it like this:
$where = sql_in_select("column", "column", "tables", "id_parent = $id_parent"));
// $where: column IN (3, 5, 7)
if ($res = sql_select('column', 'another_table', $where)) {
// ...
}
Example
Delete every link between an article and the keywords of a given keyword group:
sql_delete("spip_mots_articles", array(
"id_article=" . $id_article,
sql_in_select("id_mot", "id_mot", "spip_mots", "id_groupe = $id_groupe"));