Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
mysql语句中的大小写顺序_Mysql - Fatal编程技术网

mysql语句中的大小写顺序

mysql语句中的大小写顺序,mysql,Mysql,我一直在论坛上查看这个问题,但由于我只是一个初学者,我找不到一个答案,我可以用我的一点知识在我的代码工作。这就是我试图解决的问题: 我的店里有很多产品。有4种不同的类型 产品名称以“AA-”开头 产品名称以“BB-”开头 产品名称以“CC-”开头 产品名称以“DF-”开头 否当我向观众展示产品时,我想使用ORDER BY ASC 但对于产品“CC-”en“DF-”我希望它是按如下顺序订购的 如果我的产品名称以“BB-”开头,则应按价格订购(在select语句中也称为价格) 我知道我应该使用这个用

我一直在论坛上查看这个问题,但由于我只是一个初学者,我找不到一个答案,我可以用我的一点知识在我的代码工作。这就是我试图解决的问题:

我的店里有很多产品。有4种不同的类型

  • 产品名称以“AA-”开头
  • 产品名称以“BB-”开头
  • 产品名称以“CC-”开头
  • 产品名称以“DF-”开头
  • 否当我向观众展示产品时,我想使用ORDER BY ASC

    但对于产品“CC-”en“DF-”我希望它是按如下顺序订购的

    如果我的产品名称以“BB-”开头,则应按价格订购(在select语句中也称为价格)


    我知道我应该使用这个用例。但是我不知道具体是怎么做的。

    我想在这种情况下,你也可以很容易地选择联盟,比如:

    select t1.product_name Name, t1.product_price Price from
    
     (select product_name, product_price from shop 
      where product_name like 'cc%' or product_name like 'de%'
      order by product_name desc) t1
    
     union 
    
     select t2.* from
     ( select  product_name, product_price from shop 
       where product_name like 'bb%'
       order by product_price ) t2
    
     union 
    
     select t3.* from
     ( select product_name, product_price from shop 
       where ( product_name not like 'cc%') and ( product_name not like 'de%')
       and (product_name not like 'bb%') 
       order by  product_name, product_price) t3 ;
    

    谢谢,我会试试的