Sol Sol - 1 year ago 58
MySQL Question

Can SET in MySQL be used by itself?

I am updating some old code and couldn't find anything on this. Can

be used by itself without UPDATE? I think it was an error on the last programmer, but don't want to throw it out if it isn't.

The only way I have seen it used:

UPDATE table_name
SET column1=value1,column2=value2,...
WHERE some_column=some_value;

Here is their statement with $time being based on a timezone formula:

SET time_zone = '$time'

Here is more of the complete code:

$timezone = $_SESSION['time'];

if ($timezone < 10 && $timezone > -10) {
if ($timezone < 0) {
$timezone = substr($timezone, 1);
$offset = "-0$timezone:00";
} else {
$offset = "+0$timezone:00";
} else {
if ($timezone < 0) {
$timezone = substr($timezone, 1);
$offset = "-$timezone:00";
} else {
$offset = "+$timezone:00";
$qry= "SET time_zone = '$offset ' ";

Answer Source

It is a per connection time zone setting.

From the manual page MySQL Server Time Zone Support

Per-connection time zones. Each client that connects has its own time zone setting, given by the session time_zone variable. Initially, the session variable takes its value from the global time_zone variable, but the client can change its own time zone with this statement:

mysql> SET time_zone = timezone;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download