Mega Code Archive

 
Categories / MySQL / Select Clause
 

Using SQL Variables in Queries

mysql> SELECT @id := cust_id FROM customers WHERE cust_id=' customer name'; mysql> DELETE FROM customers WHERE cust_id = @id; mysql> DELETE FROM orders WHERE cust_id = @id;