Explain SQL strange syntax, please - 04-02-2004 , 02:29 PM
In revising some of my old MySQL scripts, existing syntax works, but
I've no reason why (or where I got it from to begin with).
Ex. Using MySQL in PHP to INSERT a row, the VALUES segment lists some
values like this:
$setsqlcall = "INSERT INTO a_table (
Most examples show simply '$aname' and '$atime'. Why the '".$var."'
syntax - extra pairings of 'double-quote & period ... period &
double-quote' inside paired single-quotes.
In searching for answers I have seen '"+$var+"' too.
Could sometime explain this for me. (Also, if you know where
explanation are to be found for this, I'd like to know that too.)
Re: Explain SQL strange syntax, please - 04-03-2004 , 04:36 PM
Robert Giden wrote:
is the concatenation operator in php, '+' in Visual Basic and maybe
PL/SQL from Oracle) 3 literal strings and 2 program variables.
Apparently a_name and a_time are not simple numeric type (Integer,
Number, Float etc.,) variables so the SQL syntax requires the
apostrophes around the corresponding values. A sample result of the
assignment, ignoring white space, might be:
INSERT INTO a_table (a_name,a_time)
If you carefully (and this can be hard in a long statement!!!) match up
the quotes (") you will see that they contain the apostrophes so that
php never sees them as php language elements, just part of the various