Compare field with multiple values from another field

Asked

Viewed 49 times

0

inserir a descrição da imagem aqui

I would like to make a SELECT based on multiple field values [jainscrito] and list only the Ids that are not in the field [jainscrito]

I’m trying unsuccessfully

$sql = "SELECT * FROM usuarios WHERE email <> '$email' AND  id NOT LIKE jainscrito ";

in case if user id=18 can only list id 20

  • By your question you can not understand exactly what you want to do. Could detail more?

  • I want to list the ID of the table that is not in the field JAINSCRITO @Francisco

  • If you use a version larger than 5.7 Mysql, change the data type of your field jainscrito for the JSON type and so you will be able to natively manipulate the values within it.

1 answer

1

From what I understand, you want to do something like this:

$sql = "select * from usuarios where email <> '$email' and ( select concat( '.', jainscrito, '.') from usuarios where email = '$email' ) not like concat( '%.', convert(id, char(5)), '.%') ";

Make sure it fits you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.