Jump to content
php.lv forumi

AND un OR vienā sql query


cipcaps

Recommended Posts

Sakiet vai tas ir iespējams, dabūt AND + OR vienā sql query.

 

Paskaidroju.

mysql_query("SELECT * FROM `tabula` WHERE `user` = '12' AND `name` LIKE 'kass%' OR `sname` LIKE 'kass%' OR `email` LIKE 'kass%'");

 

Šis sql tiek izmantots lai atgrieztu :

Info par lietotāju

kuram :

1.ID ir 12

UN

2. name sākas ar 'kass'

VAI

3. sname sākas ar 'kass'

VAI

4. email sākas ar 'kass'

 

Problēma rodas tajā, ka ja ir lietotājs ir ID 543(nevis 12) kuram name/sname/email sākas ar 'kass' tiek atgriezts info par šo lietotāju nevis 'Nav info par useri'.

 

ID ir mysqlrow int(10)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...