
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I use the @ sign in MySQL?
To use the @ sign, use MySQL SET command. The @sign is used to set user-defined variables. Following is the syntax −
SET @anyVariableName:=yourValue;
Let us first create a table −
mysql> create table DemoTable1331 -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1331 values(10,'Chris'); Query OK, 1 row affected (0.71 sec) mysql> insert into DemoTable1331 values(101,'David'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1331 values(40,'Bob'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1331 values(30,'Mike'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1331 values(60,'John'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1331;
This will produce the following output −
+------+-------+ | Id | Name | +------+-------+ | 10 | Chris | | 101 | David | | 40 | Bob | | 30 | Mike | | 60 | John | +------+-------+ 5 rows in set (0.00 sec)
Here is the query to use @sign in MySQL −
mysql> set @Value:=40; Query OK, 0 rows affected (0.00 sec) mysql> select * from DemoTable1331 where Id > @Value;
This will produce the following output −
+------+-------+ | Id | Name | +------+-------+ | 101 | David | | 60 | John | +------+-------+ 2 rows in set (0.03 sec)
- Related Questions & Answers
- How do I replace “+”(plus sign) with SPACE in MySQL?
- Do Double Equal Sign exist in MySQL?
- How do I create and use a sequence in MySQL?
- How do I use jQuery effects?
- How do I use Selenium IDE?
- How do I use arrays in C++?
- How do I use the conditional operator in C/C++?
- How do I use tabHost for Android?
- How do I use Selenium with Ruby?
- How do I use PIL with Tkinter?
- How do I set the timezone of MySQL?
- How do I use method overloading in Python?
- How do I use Python objects in C#?
- How do I lag columns in MySQL?
- How do I use capturing groups in Java Regex?
Advertisements