This may be an easy questions but i am wondering if an "insert" sql statement can be writen with equals signs.
Example: Right now my sql looks like this and works fine:
$query = "INSERT INTO people (
id,
name,
) VALUES (
{$id},
'{$name}',
)
So i was wondering if i can write the sql statement like this or something similar to this using = signs:
$query = "INSERT INTO people
id = {$id},
name = '{$site_url}',
Thank you for any help. I am just looking for an easier way to write this code especially when i have a lot of form fields. Thanks.
Insert query doesn't support where keyword* Conditions apply because you can use where condition for sub-select statements. You can perform complicated inserts using sub-selects.
In SQL, = means is equal to . (at least here; in update statements it can be an assignment Update x FROM y ... SET x.a = y.b, ... ) – wildplasser. Feb 2 at 21:06. In predicates = evaluates to true when both sides are known/bound/non-null and have the same value, as in your example above.
There are two basic syntax of INSERT INTO statement is as follows: INSERT INTO TABLE_NAME (column1, column2, column3,... columnN)] VALUES (value1, value2, value3,... valueN);
Yes.
You have to use SET
$query = "INSERT INTO people
SET id = {$id},
name = '{$site_url}'";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With