This question already has answers here:
Query with multiple likes
(2 answers)
MYSQL query - multiple likes
(1 answer)
Multiple Likes in SQL
(1 answer)
Select Command with Multiple LIKEs
(2 answers)
mysql multiple OR NOT LIKES
(2 answers)
Closed 5 years ago.
How can I search in 3 columns with LIKE?
the following code gives an error
$sql .= " AND (Genre, Genre2, Genre3) like '%$s2%'";
full sql;
SELECT * FROM films where Title_ing like '%$s1%' OR Title_de like '%$s1%' AND (Genre like '%$s2%' OR Genre2 '%$s2%' OR Genre3 '%$s2%') AND imdbRating like '$s3%'
You need to use OR
AND (Genre like '%$genre%' OR Genre2 '%$genre%' OR Genre3 '%$genre%');
Related
This question already has answers here:
PHP PDO retrieves duplicate data
(2 answers)
Closed 1 year ago.
I'm newbie in PHP and when I use PHP to query select, I got 2 values, I realize it may be make slow if have 2 duplicated values.
So I want to ask about it and I also want to get just 1 values from select
thanks for reading my question.
here is picture:
It dipends on what your i guess sql query respondes to your query. However if you want cut down your result in sql you can use LIMIT 1
SELECT ...
FROM ...
WHERE ...
LIMIT 1
This question already has answers here:
SQL select only rows with max value on a column [duplicate]
(27 answers)
Retrieving the last record in each group - MySQL
(33 answers)
Closed 3 years ago.
I have a problem to show one of duplicate data with last created date. This is is my query :
$sqlpur ="SELECT DISTINCT pn, created_date, id_purchase FROM pur_supp ORDER BY pn, created_date DESC";
This is the result.
This is a data from database.
But, I want to show just one of duplicate data. an example just to show 02N64073 with last created Date.
This question already has answers here:
How can I prevent SQL injection in PHP?
(27 answers)
Closed 4 years ago.
How can I select a row in MySQL db where the value of a column contains ' and \ ?
For example, I want to select a column that matches this types of string:
https://www.mayoclinic.org/diseases-conditions/hirschsprung\'s-disease/symptoms-causes/syc-20351556
What can I do to achieve what I want?
This should work, both characters must be escaped into the query:
SELECT * FROM `urls` WHERE text LIKE "%\\\\\'%"
This question already has answers here:
How to retrieve the last 4 characters from a mysql database field?
(4 answers)
Getting last 5 char of string with mysql query
(6 answers)
Query to select strings end with certain character
(6 answers)
Closed 5 years ago.
this is my data in the database and i'm using mysql
database image
How do I retreive number "4" from the data using sql command?
USE reverse and left
set #myfield = 1234;
select left(reverse(#myfield),1) as result;
result
4
demo here
http://rextester.com/LTBE34983
This question already has answers here:
MySQL offset infinite rows
(10 answers)
Closed 9 years ago.
I have the following SQL code;
SELECT * FROM myTable WHERE id = 1 LIMIT 4, 10;
I would like the sql to run from result 4 but have no end limit, so I would like the script to get all the results from 4 onwards. Is this possible?
Any help appreciated.
You can use the OFFSET option in your query. Like this
SELECT *
FROM myTable
WHERE id = 1
OFFSET 4
SELECT * FROM tbl LIMIT 4, 18446744073709551615;
resource mysql docs.