%和_都是数据库里的通配符,%是替代任意长度的任意字符,_是替代一个任意字符, 例如表A里又记录: col1 col2 123 asd 12 asdf 134 asdfasdf 那么: select * from table where name like "1%" 结果: col1 col2 123 asd 12 asdf 134 asdfasdfselect * from table where name like "1_" 结果: col1 col2 12 asdfselect * from table where name like "1__" 结果: col1 col2 123 asd 134 asdfasdf
写错了一点,是select * from A where ………… (不是select * from table where ……)
ft,脑子怎么了,还是写错了,是 select * from A where col1 like "1%" 结果: col1 col2 123 asd 12 asdf 134 asdfasdfselect * from A where col1 like "1_" 结果: col1 col2 12 asdfselect * from A where col1 like "1__" 结果: col1 col2 123 asd 134 asdfasdf
where name like 'my%'
2 先看书,再干事
例如表A里又记录:
col1 col2
123 asd
12 asdf
134 asdfasdf
那么:
select * from table where name like "1%"
结果:
col1 col2
123 asd
12 asdf
134 asdfasdfselect * from table where name like "1_"
结果:
col1 col2
12 asdfselect * from table where name like "1__"
结果:
col1 col2
123 asd
134 asdfasdf
select * from A where col1 like "1%"
结果:
col1 col2
123 asd
12 asdf
134 asdfasdfselect * from A where col1 like "1_"
结果:
col1 col2
12 asdfselect * from A where col1 like "1__"
结果:
col1 col2
123 asd
134 asdfasdf
我就是这么蒙混过关的.