473,385 Members | 2,015 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Variables in MySQL

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
Jul 19 '05 #1
0 980

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jack | last post by:
Hi All, What is the PHP equivilent of Oracle bind variables in a SQL statement, e.g. select x from y where z=:parameter Which in asp/jsp would be followed by some statements to bind a value...
0
by: Martin MOKREJ© | last post by:
Hi, I need to build 3 classes for my work, but each have dozens or hundreds of variables, self bound. I have about 250 columns in about 10 mysql tables. I can squeeze everything into 10 classes,...
0
by: Nils Valentin | last post by:
Hello MySQL Fans, This time I am using 4.0.13-max (tar format from www.mysql.com) on Redhat 9. I have an understanding question why would the command SHOW VRAIABLES give me once the real...
0
by: James E Koehler | last post by:
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...
2
by: Sami | last post by:
I keep getting the famous 'Too Many Connection' Error, and don't know how to change my variables, so they persist even if i have to restart mysql service. Platform: Windows 2003 Server My...
6
by: Raqueeb Hassan | last post by:
Hello There! Have you guys tried inserting variables in mySQL tables? Do I have to use 'quote' as we had been doing to insert strings? mysql> INSERT INTO occurrence (word_id,page_id) VALUES...
6
by: Grainne Reilly | last post by:
I am new to PostgreSQL and am porting some scripts written for MySQL over to psql. There is one MySQL feature which I cannot find in psql - user defined SQL variables. In MySQL I can use these to...
10
by: EOZyo | last post by:
Hi, i'm trying to set pagination for a search i run on my website, i'll try to explain the easiest i can: When i click the search button on search.php, data is received and stored in variables...
0
by: Jeff | last post by:
I'm a bit new to visual web using VB (.net 2005). I'm using this in conjunction with MySQL and am starting to get the hang of things. Here is the question: I've been able to do essentially the...
19
by: Mitesh | last post by:
Hi all, I have the following code: $req = "SELECT * FROM table1"; $res = mysql_query($req); if(!$res) return;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.