LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 04-15-2013, 10:23 AM   #1
waynesch
LQ Newbie
 
Registered: Jun 2006
Posts: 3

Rep: Reputation: 0
MySQL user defined variable


I am using MySQL 5.1.54 and would like to define a user variable. Have tried the following with no results.

use business
select name,c_num
from clients
where rep='@rep';

set @rep=rep
@rep=3 or @rep:=3

Does any one have any idea what I am doing incorrect?

Thank you,
wayne
schmtzway@yahoo.com
 
Old 04-15-2013, 08:42 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
This seems to cover it https://dev.mysql.com/doc/refman/5.1...statement.html
Code:
mysql> select * from tab1;
+---------+------+
| v1      | n1   |
+---------+------+
| teststr | NULL |
+---------+------+
1 row in set (0.00 sec)


mysql> set @my='teststr';
Query OK, 0 rows affected (0.00 sec)

mysql> select * from tab1 where v1=@my;
+---------+------+
| v1      | n1   |
+---------+------+
| teststr | NULL |
+---------+------+
1 row in set (0.00 sec)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get value for variable name defined as string webquinty Programming 4 11-18-2009 06:30 AM
I try to set a user defined variable but it understands a command albinworld Linux - Newbie 3 01-03-2009 02:42 PM
MySQL - Needed enforcing of a user defined directory for the database. Nimoy Programming 1 10-25-2007 10:25 AM
Replace variable with user defined variable ce124 Programming 10 04-13-2007 10:29 AM
FYI: Creating User Defined Functions for MySQL mchirico LinuxQuestions.org Member Success Stories 1 06-11-2004 09:51 PM


All times are GMT -5. The time now is 10:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration