Hello,
I need a little help.
I am new to MySQL and am trying to acquire skills in MySQL without the
benefit of any formal training although I have been in IT for more
years than I care to admit (retired now). I have bought and read
several SQL and MySQL books and frequently reference the on-line MySQL
manual on http://www.mysql.com/doc/en/index.html. I have also browsed
this and related newsgroups with considerable benefit.
For all of my efforts I seem to have missed some basic points
regarding the use of variables in MySQL scripts.
I hope that the readers of this posting do not find the problem
described in the example code below too silly or trivial to comment
on.
Please advise me if I have chosen the wring newsgroup for this
posting.
As the example code shows, all I a trying to do is set a variable (v)
to the current contents of the cell in column i, row 1 of table t.
DROP TABLE IF EXISTS t;
CREATE TABLE t
(
i INT(2),
r int(2) NOT NULL auto_increment,
PRIMARY KEY (r)
);
INSERT t SET i = 1;
# This is the line that fails.
SET @v = SELECT i FROM t where r = 1;
The version of MySQL that I am using is 4.0.6-gamma-win. It throws
back the above code with a bland error message that does not indicate
what the problem is.
Am I wrong in thinking that variables can be used in this way in
MySQL?
Assuming that I eventually get variables to work I intend to set up a
while loop for going through the rows of a table referencing the cells
in several columns.
Thank you very much for your assistance.
J E koehler