LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 09: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, 07:42 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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 05:30 AM
I try to set a user defined variable but it understands a command albinworld Linux - Newbie 3 01-03-2009 01:42 PM
MySQL - Needed enforcing of a user defined directory for the database. Nimoy Programming 1 10-25-2007 09:25 AM
Replace variable with user defined variable ce124 Programming 10 04-13-2007 09:29 AM
FYI: Creating User Defined Functions for MySQL mchirico LinuxQuestions.org Member Success Stories 1 06-11-2004 08:51 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 10:15 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
Open Source Consulting | Domain Registration