MySQL Commands
//select database
mysql> use [databasename]
//show all databases
mysql> show databases;
//show database tables
mysql> show tables;
//describe table, must have the database selected
mysql> show tables;
//a search query that allow regular expressions
SELECT * FROM customers WHERE city like 'Air%';
//create table, must have a type after the name. eg: name=customerid, type=text
create table books
(customerid text, name text);
//delete table
drop table balls;
//insert values
insert into customers values
(null,'blahblah', 3);
//connecting subqueries
select name from customers where customers.customerid = any (select orders.orderid from orders,order_items where orders.orderid = order_items.orderid);
//Update record
update books set price = price1.1;
//alter table, add columns. its like create table, name and type
alter table books
add (tax text);
alter table books
drop tax;
//delete record
delete from customers
where cus
No comments:
Post a Comment