473,396 Members | 1,924 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,396 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 1247

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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.