› MySQL 5.5 Community Server
› MySQL 5.6 Community Server
› Percona Configuration Wizard
› XtraBackup 搭建主从复制
Great Sites on MySQL
› Percona
› MySQL Performance Blog
› Severalnines
推荐管理工具
› Sequel Pro
› phpMyAdmin
推荐书目
› MySQL Cookbook
MySQL 相关项目
› MariaDB
› Drizzle
参考文档
› http://mysql-python.sourceforge.net/MySQLdb.html
zhouzhou113
V2EX  ›  MySQL

vs 调用 mysql 查询语句怎样添加变量?

  •  
  •   zhouzhou113 · Dec 19, 2018 · 4125 views
    This topic created in 2841 days ago, the information mentioned may be changed or developed.

    QSqlQuery query; query.exec(QObject::tr( "select * from lookuptable where index_num = '%1'" ). arg(indexnum,0,'r',4));

    上述两行是使用 QT 的 sql 查询函数,查询语句添加了变量 indexnum

    直接在 vs2005 里面调用 mysql8.0.13 的查询语句是这样子的:

    mysql_query(&mysql, "select * from lookuptable where index_num =200413018016021");//编译可通过

    改成如下变量形式的,其中 indexnum 是 double 型,str_indexnum 是 indexnum 转 string

    1.mysql_query(&mysql, "select * from lookuptable where index_num ="+indexnum);

    报错: error C2111: “+”: 指针加法要求整型操作数

    2.mysql_query(&mysql, "select * from lookuptable where index_num ="+str_indexnum);

    报错: error C2664: “ mysql_query ”: 不能将参数 2 从“ std::basic_string<_Elem,_Traits,_Ax>”转换为“ const char *”

    请教加变量的查询语句应该怎么写?谢谢

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2799 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 14:30 · PVG 22:30 · LAX 07:30 · JFK 10:30
    ♥ Do have faith in what you're doing.