This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 5 years ago.
I am trying to execute the following query:
SELECT * FROM inbound WHERE direction = 'inbound' AND shortcode IN (60777) AND trigger IN (G6AAJ) ORDER BY daterecieved DESC LIMIT 1
But I get the error:
#1054 - Unknown column 'G6AAJ' in 'where clause'
I cannot figure out why, any with this help appreciated.
It's interpreting G6AAJ as a column name, try IN ('G6AAJ')
Related
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Reference - What does this error mean in PHP?
(38 answers)
Closed 4 years ago.
could someone help me fix the below code please:
$decision = mysqli_real_escape_string($conn, $_POST['decision']);
$sql = "SELECT * FROM user1 WHERE 'fao' LIKE '%decision%' AND id NOT IN
(SELECT id FROM assigned)";
$result=mysqli_query($conn, $sql);
fao field only ever has two values, Nurse or Dietitian. The issue is with my SELECT statement. In the assigned table, there are two columns, an id value and the name of a user. What I am trying to do is if the id value exists in 'assigned' table, then I would like to remove this from the results of SELECTing all from 'user1'. I am then echoing these results into a table. Thanks!
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
SELECT 'club_profile.'club_name_link','players'.'player_name_link'
FROM club_profile
INNER JOIN players ON 'club_profile'.'club_name_link'
OR 'players'.'player_name_link'
LIKE '%".$category_result."%'
LIMIT 0,10");
Result I got
Parse error: syntax error, unexpected '$category' (T_VARIABLE) in C:\xampp\htdocs\scoresfield\admin\post.php on line 22
You should not use single quotes for tables and columns name .. when necessary use backtics
"SELECT club_profile.club_name_link,players.player_name_link
FROM club_profile
INNER JOIN players ON club_profile.club_name_link
OR players.player_name_link
LIKE concat('%','".$category_result."','%' )
LIMIT 0,10");
( the use of $var is deprecated because can permit sqlinjection
take a look at the sql driver you are using and use parameter binding instead)
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Closed 5 years ago.
I have db like this :
id, name, group.
(Group is a slug, that I can't know for my request)
So one group can have many name.
I want to sort by group with php/mysql.
I want get something like this :
$request = array( 'groupeOne = array ('name')', 'groupeTwo = array()' )
Something like this. I try to order by group but it doesn't work
You can use
order by
`group` (using backtics ..because group is a reserver word
select tid, name, `group`
from my_table
order by `group`
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 6 years ago.
I use below php code to generate a random id number
md5(uniqid(rand(), true)
the type of string it generate is something like this
9a423553ce53c4d7a6199fa9254bfdc5
I use that as an ID in Mysql table then I do a standard select query
SELECT * FROM table WHERE id = 9a423553ce53c4d7a6199fa9254bfdc5
I get this error
Unknown column '9a423553ce53c4d7a6199fa9254bfdc5' in 'where clause'
if I just change the id to a simple number like 1 it works.
Why is this?
Have you tried encapsulating that in quotes? In your query id = 9a423553ce53c4d7a6199fa9254bfdc5 You can compare two columns like id = other_id .. MySQL needs to know how to handle your query.
For clarification, should be: SELECT * FROM table WHERE id = '9a423553ce53c4d7a6199fa9254bfdc5';
This question already has answers here:
When to use single quotes, double quotes, and backticks in MySQL
(13 answers)
Closed 7 years ago.
I'm converting all MySQL to MySQLi pages. I need to select all rows where a column starts with a letter.
On MySql If I want all rows starting with P, I used to add % to P, so I'll search all entries LIKE P%, but it's not working on MySQLi
If $type = P%
$result = $mysqli->query("SELECT * FROM my_table WHERE column LIKE $type");
I get no results.
I appreciate any help you can provide.
Try putting quotes around the variable in the query so that it looks like this :
$result = $mysqli->query("SELECT * FROM my_table WHERE column LIKE '$type'");
This will probably solve the problem.