I would like to select 2 different variables from my database. I wrote it like this:
$sql = "SELECT * FROM `Catalog` WHERE title = '{$article['alsolike']}' OR '{$article['alsolike2']}' ";
That does not seem to work.
The idea would be that it would output as such:
$sql = "SELECT * FROM `Catalog` WHERE title = 'Germany' OR 'Ireland' ";
How would this be written correctly?
"OR" in SQL Query
Moderator: General Moderators
Re: "OR" in SQL Query
OR in SQL works just like OR in every other programming language out there.
"Ireland" is not a condition.
Code: Select all
condition OR condition OR condition...- SimpleManWeb
- Forum Commoner
- Posts: 57
- Joined: Wed Dec 30, 2009 4:15 pm
- Location: New Hampshire, USA
Re: "OR" in SQL Query
To further elaborate,"Ireland" is not a condition
Code: Select all
$sql = "SELECT * FROM `Catalog` WHERE title = 'Germany' OR `title` = 'Ireland' ";
For your first query, use this:
Code: Select all
$sql = "SELECT * FROM `Catalog` WHERE title = '".$article['alsolike']."' OR `title` = '".$article['alsolike2']."' ";
Re: "OR" in SQL Query
Thanks, that makes sense.
I suffer from a condition called Ireland. I'm learning to deal with it.
I suffer from a condition called Ireland. I'm learning to deal with it.