ERROR 1418: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators&n……
CREATE FUNCTION `getGroupCID`(pid varchar(5000)) RETURNS VARCHAR(5000) DETERMINISTIC BEGIN DECLARE children VARCHAR(5000); SELECT group_concat(id) INTO children FROM group_info WHERE FIND_IN_SET(group_info.pid, pid); IF children ……
DELIMITER $$ CREATE FUNCTION `getParent`(n INT) RETURNS VARCHAR(255) BEGIN DECLARE parent VARCHAR(2555); SELECT parent_id INTO parent FROM your_table WHERE id = n; IF parent IS NOT NULL THEN ……
INSERT INTO db1_name(field1,field2) SELECT field1,field2 FROM db2_name当然,上面的语句比较适合两个表的数据互插,如果多个表就不适应了。对于多个表,我们可以先将需要查询的字段join起来,然后组成一个视图后再select from就可以了:
&n……
select * from article where FIND_IN_SET('4',type)----------------------------------------------------------
MySQL的sql语句有好多可以省去服务器端的复杂处理,比如mysql将查询的单列结果集拼成一行字符串用逗号分隔
group_concat
这玩意儿可以实现 将一个字段如id查询出来 成为这样的格式:121,122,123,124,125,126
select group_concat(id) as nids from 表名 搞定