MySQL的基本用法

1。建表

CREATE TABLE tbl_order_confirm(
    orderid          CHAR(16)        NOT NULL,
    dealid           VARCHAR(64)     NOT NULL,
    bankdealid       VARCHAR(20),
    orderamount      FLOAT(6, 2)     NOT NULL,
    payamount        FLOAT(6, 2)     NOT NULL,
    cardnumber       VARCHAR(18),
    cardpwd          VARCHAR(18),
    ordertime        TIMESTAMP       NOT NULL,
    confirmdate      TIMESTAMP       NOT NULL,
    status           CHAR(1)         NOT NULL,
    failurereason    VARCHAR(100),
    PRIMARY KEY (orderid)
)ENGINE=INNODB
COMMENT='订单确认表'
;

 

2。查询数据:
SELECT * FROM tbl_coin WHERE uno in (select uno from tbl_user where userid='hairongn')

SELECT * FROM tbl_coin WHERE mno =3
select uno from tbl_user where userid='hairongn'(查询uno从表格tbl-user 里面根据userid)

 

3。插入数据
insert into test(uno,mno,balance,status,createdate) values (222278892,300,500,'A','2012-06-01 15:22:33');

 

4删除数据:
delete from test where status='A';  (删除表test里面所有状态为A的记录)

5。更新数据

UPDATE table_name SET width = 100  where  id=5    (更改width为100,在id=5的这条记录里面)

 

 

posted on 2010-07-21 16:28  lovening  阅读(114)  评论(0编辑  收藏  举报