› 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
icemanpro
V2EX  ›  MySQL

支不支持 if exists()?

  •  
  •   icemanpro · Feb 7, 2021 · 2558 views
    This topic created in 2060 days ago, the information mentioned may be changed or developed.
    像这样的,在 mysql 如何写?
    IF EXISTS(SELECT * FROM shares WHERE file_id='1' AND user_id='4') THEN
    SELECT * FROM shares WHERE file_id='1' AND user_id='4'
    ELSE
    SELECT * FROM shares WHERE file_id='2' AND user_id='5'
    END IF
    1 replies  •  2021-02-07 11:50:08 +08:00
    ElmerZhang
        1
    ElmerZhang  
       Feb 7, 2021
    SELECT * FROM shares WHERE ( file_id='1' AND user_id='4' ) OR (file_id='2' AND user_id='5') ORDER BY file_id ASC LIMIT 1;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   968 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 22:35 · PVG 06:35 · LAX 15:35 · JFK 18:35
    ♥ Do have faith in what you're doing.