在 mysql 中,我们经常用 in 来查询众多数据中是否有数据表字段中的值: 如果我们在数据表的字段中添加了很多值,然后查询某个值是否是这个字段中众多值的一个时可以用 find_in_set('数据',字段名) 语句 注:仅适用sql原生语句: $bj = Db::query("select * from think_class where find_in_set($stuid,stuid)");…
作为示例,我们在这里使用名为testdb的数据库,并且在其中创建两张一模一样的表: drop table if exists test_table_1; create table test_table_1 ( name varchar(30) primary key, age integer ); drop table if exists test_table_2; create table test_table_2 ( name varchar(30) primary key, age int…
今天一下要记录一下才行了,每次都要去网上查找方法,每次都难找得要命 Mysql在更新某些字段的数据时,有时候会依据其他表的数据进行更新,需要通过关联后对不同的行更新不同的值,传统的update set没法实现,可以用下面的方法来实现 UPDATE `widetable_solr_field` a INNER JOIN `widetable_field_increat` b SET a.`compose` = b.`udf` WHERE a.`fname` = CONCAT('t',b.`tabl…
### part1 单表查询 sql查询完整语法: select .. from .. where .. group by .. having .. order by .. limit .. 一.where 条件的使用 """功能:对表中的数据进行过滤筛选""" """ 语法: 1.判断条件的符号 = > < >= <= != <>(不等于) 2.拼接条件关键字 and or no…