Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-02-2003, 02:08 AM   #1
Registered: Jun 2003
Posts: 92

Rep: Reputation: 15
mysql statement...

hello, i'm runing rhat9 with mysql, the question i got it's when i insert this sql statement.. the second row should't show up.. because
1st condition commission > 10 which = true
surname='Rive' which = false
first_name='Sol' which = false

so True OR false = True
True AND false = false; ???

mysql> SELECT * FROM sales_rep WHERE commission>10
OR surname='Rive' AND first_name='Sol';
| employee_number | surname | first_name | commission |
| 1 | Rive | Sol | 10 |
| 2 | Gordimer | Charlene | 15 |
2 rows in set (0.00 sec)


Old 11-02-2003, 03:30 AM   #2
Senior Member
Registered: Apr 2003
Location: Eire
Distribution: Slackware 12.0, OpenSuse 10.3
Posts: 1,120

Rep: Reputation: 45
SELECT * FROM sales_rep WHERE commission>10 AND (surname='Rive' AND first_name='Sol');

The second row will show up because it meets the first part of the OR test namely their comission is greater than 10. OR means only one part of the comparision has to be true, AND means all parts. Use brackets to clarify things. It's difficult to see for sure whether you are trying to select all sales_rep's with commission greater than ten or the sales rep Rive Sol. Above should only select Rive Sol if their commission is greater than 10 but try and it and see.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM
the FOR statement (C) sk84blood813 Programming 3 12-09-2004 08:25 AM
If Statement junjem0702 Programming 4 08-23-2004 09:49 AM
how to run the mysql load statement in cron gschrade Linux - Software 5 07-27-2004 02:27 PM
mysql sql statement help mrtwice Programming 4 12-02-2003 10:04 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration