Jump to content

Recommended Posts

SELECT `id`,`title`,`date` FROM `messages` WHERE `opened` = '1' AND `status` = '0' OR `status` = '1' AND ". time() ." - `timestamp` < '7889231' AND `receiver` = '!' OR `receiver` = ? ORDER BY `date` DESC

 

In PHP it would be similar to:

 

if(($t = 1 || $t == 2) && $rank < 3)

 

How can I do something similar with this query? In the beginning of the query, you see that the OR throws it off. Is there a way I can do something similar the way PHP does it where:

 

`status` = '0' OR `status` = '1'

 

So in PHP, it would be:

 

if($status == 0 || $status == 1) && $var == 1 && $var == 2)

 

Sorry if I was bad at explaining what I'm looking for.  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/264791-mysql-query-with-a-lot-of-ands-and-ors/
Share on other sites

parenthesis... not brackets ;)

 

well.. even when this is not a grammar forum... do you know that PARENTHESES (Plural) or parenthesis (singular) are a TYPE OF BRACKETS? ... specifically they are ROUND BRACKETS, and how you call'em in reality depends on which side of world you are. 

 

The OP sure is smart enough to understand what to use, moreover when I did quote his own line of code.

 

FYI

Types of Brackets:

( ) ? round brackets, open brackets, close brackets (UK), or parentheses

[ ] ? square brackets, closed brackets, or brackets (US)

{ } ? curly brackets, definite brackets, swirly brackets, curly braces, birdie brackets, Scottish brackets, squirrelly brackets, braces, gullwings, seagull, fancy brackets, or DeLorean Brackets[citation needed]

⟨ ⟩ ? pointy brackets, angle brackets, triangular brackets, diamond brackets, tuples, or chevrons

< > ? inequality signs, pointy brackets, or brackets. Sometimes referred to as angle brackets, in such cases as HTML markup. Occasionally known as broken brackets or brokets.[1]

? ?; ? ? ? angular quote brackets, or guillemets

⸤ ⸥; 「 」 ? corner brackets

Thanks for the reply guys!  8)

 

Edit: I tried: WHERE `opened` = '1' AND (`status` = '0' OR `status` = '1') AND ". time() ." - `timestamp` < '7889231'

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1340745722 - `timestamp` < '7889231' ORDER BY `date` DESC' at line 1No conversations in this section.

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.