MySQL operation

Loading Data into a Table

(1)Loading data from a file like this:
mysql> LOAD DATA LOCAL INFILES '/path/pet.txt' INTO TABLE pet
->LINES TERMINATED BY '\r\n';
**if generate a load error,like the command is not useful,
when entry mysql,add this “local_infile=1”
for instance:
mysql -u root - p –local-infile=1 -e “LOAD DATA LOCAL INFILE “/path/text” INTO TABLE XXX FILEDS TERMINATED BY ‘,’**
(2)directly insert:
mysql> INSERT INTO pet
-> VALUES('paffbal','diane','1990-03-30',NULL);

Retrieving information from a table

The general form of the statement is:
SELECT what_to_select
FROM which_table
WHERE conditions_to_satisfy
ORDER BY which_column;
the default sort order is ascending,if what to in reverse order add DESC keyword to the name of the column you sorting by.
you can sort on multiple columns,and you can sort different columns in different directions.
When you do an ORDER BY ,NULL values are presented first.

Pattern matching

SQL pattern matching enables you to use “_” to match any single character and “%” to match an arbitrary number of characters.In MySQL, SQL patterns are case-insensitive by default.You do not use = or <> when you use SQL patterns, use the LIKE or NOT LIKE comparison operation instead.
to find names beginning with “b”:
mysql> SELECT * FROM pet WHERE name LIKE 'b%';
to find names ending with “fy”:
mysql> SELECT *FROM pet WHERE name LIKE '%fy';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值