l863037867
l863037867
采纳率0%
2016-05-31 13:18 阅读 6.4k

求一个sql语句,查出字段中包含某一个值的记录

5

Ileibie bianhao
T前沿 I001
人文科学 R001
其他 Q001
历史经典 L001 比如我要找bianhao列的 R001

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

10条回答 默认 最新

  • u012601647 菜鸟小灰灰 2016-05-31 13:25

    select * from A where bianhao = 'R001'

    点赞 评论 复制链接分享
  • l863037867 l863037867 2016-05-31 13:28

    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'J001' in 'where clause'
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.Util.getInstance(Util.java:386)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2678)
    at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
    at 图书馆.TuShuXinXijiemian.trycatch(TuShuXinXijiemian.java:43)
    at 图书馆.TuShuXinXijiemian.start(TuShuXinXijiemian.java:96)
    at 图书馆.SelectBookID.trycatch1(SelectBookID.java:80)
    at 图书馆.SelectBookID.lambda$1(SelectBookID.java:45)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    Connection链接成功!
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at javafx.scene.Node.fireEvent(Unknown Source)
    at javafx.scene.control.Button.fire(Unknown Source)
    at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
    at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
    at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
    at javafx.event.Event.fireEvent(Unknown Source)
    at javafx.scene.Scene$MouseHandler.process(Unknown Source)
    at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
    at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
    at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
    at com.sun.glass.ui.View.notifyMouse(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

    
    ```报错
    
    
    点赞 评论 复制链接分享
  • wanger2014 wanger2014 2016-05-31 14:16

    sql的话, 楼上这句select * from A where bianhao = 'R001'理论上可以, 但是你的日志代码里,
    com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'J001' in 'where clause,这是什么回事?
    建议select * from A where bianhao = 'R001' 在执行语句后加分号试试,可能你后面还有语句。
    或者测试select * from A where bianhao like '%R001';在sql中试试。

    点赞 评论 复制链接分享
  • qq_32102181 loveFamily1234 2016-05-31 14:36

    是不是你的表名与某个字段名相同了

    点赞 评论 复制链接分享
  • y472541642 json_ycp 2016-05-31 14:42

    SELECT * FROM A WHERE bianhao like '%R001';

    点赞 评论 复制链接分享
  • ZQUly ZQUly 2016-05-31 14:57

    select 属性名 from 表名 where 某个属性名 like '%xxx%' 用like关键字 %号表示后面可以是任意多个字符

    点赞 评论 复制链接分享
  • duanchuanzhi 积零为整 2016-05-31 15:26

    这是要用模糊查询吗 select * from 表 where 值的字段名 like '%你需查的值%';

    点赞 评论 复制链接分享
  • wzxq123 尚书左仆射 2016-06-01 00:55

    你的biaohao只是列名,你的表名是什么没说啊。

    点赞 评论 复制链接分享
  • qq_35175797 GuoChilde 2016-06-01 00:57

    select * from A where bianhao = 'R001'; mysql 语句结束后,需要加分号,你那报错,建议检查下表结构,看字段名是否正确

    点赞 评论 复制链接分享
  • huyanghucf huyanghucf 2016-06-01 01:43

    select 字段名 from A where bianhao = 'R001';

    点赞 评论 复制链接分享

相关推荐