douzhuanfen5923 2018-06-05 10:36
浏览 77
已采纳

如何在MySQL查询的结果中找出特定列的值?

I have a table with the following columns: id, firstname, lastname, category. And let's say i have data with categories like: action, comedy, drama, horror. My query is

SELECT * FROM tablename WHERE firstname LIKE '%John%'

The query will bring all the records that contain 'John' in firstname, and let's assume that the records have different values for categoty: action and comedy only.

How to find out the list with all the values available in category column for this specific search.

Thanks!

  • 写回答

4条回答 默认 最新

  • dongluan2612 2018-06-05 10:43
    关注

    If you want a distinct list of categories, where firstname is like John:

    SELECT DISTINCT category FROM tablename WHERE firstname LIKE '%John%'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 docker环境配置
  • ¥20 绿盟安全扫描--检测到目标站点存在javascript框架库漏洞
  • ¥30 Android STD快速启动
  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现