$sql = "
CREATE TABLE IF NOT EXISTS `" .$prefix."account_log_".trim($_POST['tab_head'])."` (
`log_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`user_id` mediumint(8) unsigned NOT NULL,
`admindo` varchar(50) NOT NULL,
`admin_id` mediumint(8) unsigned NOT NULL,
`user_money` decimal(10,2) NOT NULL,
`frozen_money` decimal(10,2) NOT NULL,
`rank_points` mediumint(9) NOT NULL,
`pay_points` mediumint(9) NOT NULL,
`change_time` int(10) unsigned NOT NULL,
`change_desc` varchar(100) NOT NULL,
`change_type` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`log_id`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1
"
$db->query($sql)
MySQL 处理动态 SQL需要用
PREPARE sl FROM @sql
EXECUTE sl
DEALLOCATE PREPARE sl
这样的语句。
MySQL 动态SQL 的例子 如下
http://hi.baidu.com/wangzhiqing999/blog/item/8db9453d31a9a9fc3b87ce4c.html
单纯的SQL没有这么写的,如果是其他程式开发语言,可以直接拼SQL;如果是存储过程,可以试试动态SQL
set @sql_1 = " select * from .......limit ? "
prepare stmt from @sql_1
execute stmt using @step
deallocate prepare stmt
commit
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)