首先,你至少应该告诉回答你问题的人,product、catalogs表的结构是什么样的,
而不是等着别人去看你的sql语句来分析。

解决方案 »

  1.   

    好。等我哦。
    这是catalogs:
     menuid  int(11)   否    auto_increment              
       menustep  varchar(255)   否                  
       menuname  varchar(255)   否                  
      这是product:
                 
       commid  bigint(20)   否  0                
       name  varchar(150)   否                  
       catalog  int(11)   否  0                
       sorts  int(11)   否  0                
       smlcatalog  int(11)   否  0                
       manufacturer  int(11)   否  0                
       wholesaler  int(11)   否  0                
       w_itemid  varchar(100)   否  0                
       inprice  varchar(20)   否                  
       price  varchar(20)   否                  
       etprice  varchar(20)   否  0                
       stock  int(11)   否  0                
       tax  varchar(10)   否                  
       shipping  varchar(11)   否  0                
       model  varchar(100)   否                  
       description  text   否                  
       detail  text   否                  
       drumbeating  text   否                  
       specialdetail  varchar(255)   否                  
       weight  varchar(10)   否                  
       images  varchar(255)   否                  
       rebate  int(1)   否  0                
       comefrom  varchar(255)   否                  
       warranty type  int(11)   否  0                
       warranty price  int(11)   否  0                
       warranty duration  int(11)   否  0                
       inputtime  datetime   否  0000-00-00 00:00:00                
       display  int(1)   否  0 
      

  2.   

    Debian(乌鱼子)快看呀。我给了表结构呀。
      

  3.   

    粗略的看了一下,你说的“又有点不是按序的”是出现在menuname上吧。
      

  4.   

    menuname是中文还是英文,还是混杂?
    如果是中文,你试试看设置mysql的default-character-set = gb2312,
    看看是否有用,中文确实是个头痛的问题。
      

  5.   

    晕了,我试了。
    后面的ORDER BY 条件,我试了很多种,还就只有这种是排序排的最顺的。
    其它,一团糟。。
      

  6.   

    请告知查询串中
    ... order by product.catalog , product.sorts and catalogs.menuname, catalogs.menunameproduct.sorts and catalogs.menuname 的含义。为什么要这么写?
      

  7.   

    我要的是:
     首先按catalog分大类,然后在catalog里分sorts类。
     然后在sorts包括许多的smlcatalog。
    而且:
     每类都要按字段的字母的降序排列。... order by product.catalog desc, product.sorts desc,catalogs.menuname desc
      

  8.   

    就是sorts按名称的字母排序的意思。
      

  9.   

    不会的呢。
    改成... order by product.catalog desc, product.sorts desc,catalogs.menuname desc
    之后,就成乱的了。
    比如:
    第一个是Notebooks的catalog类。然后。下一个却会是Digital Cameras的catalog类。
    再下一个却又是Software的catalog类。
    而在sorts里的顺序也是杂乱的。
    我的本意就是按它本身的名称的Z.X.Y...这样排下去。
      

  10.   

    因为你前面有group by product.catalog, product.sorts, product.smlcatalog 分组
    所以排序是在分组中进行的,每组都是按catalog, sorts,menuname 排序的
      

  11.   

    嗯,但,如果我只ORDER BY menuname这一项的话,也并不会达到正确的结果呀。
    而更是乱。一下D...一下又C...一下又N...
      

  12.   

    SELECT product. * , catalogs. * 
    FROM product, catalogs
    WHERE ( product.smlcatalog = catalogs.menuid OR product.sorts = catalogs.menuid )
    GROUP  BY product.catalog, product.sorts, product.smlcatalog order by catalogs.menuname, product.sorts, product.name由于你对catalog,sorts,smlcatalog三者关系解释清楚,我无法知道三者的层次关系。
      

  13.   

    再说一遍:当有分组时,(使用了group子句)排序将在组中进行!
      

  14.   

    没错,使用GROUP BY时结果是在分组得列上进行排序,所以需要ORDER BY来控制次序。
      

  15.   

    当有分组时,(使用了group子句)排序将在组中进行!
    我知道,你不觉得我就是要表达这个意思嘛?
    问题是,如果我按这个意思写的话,根本就没有用嘛。
      

  16.   

    你怎么区分catalog,sort,smlcatalog?他们之间的关系如何?
      

  17.   

    catalog,sort,smlcatalog都是从catalogs.menuid字段得到数据。
      

  18.   

    Computer Hardware   
     Accessories  
     
    ¤Surge Suppressors ¤Accessories - CPU 
    ¤Fans & Thermal Controllers ¤Card Reader/Adapter 
    ¤Cables ¤Accessories - Hard Drive 
    ¤Accessories - Video Card ¤Accessories-Printer 
    ¤Accessories - USB ¤Accessories - Case 
    ¤Digital Media Remote 
     
     
     Network Devices  
     
    ¤Bluetooth 
     
     
     CD DVD Rom/R/RW   
     
    ¤CDRW/DVD Combo ¤CD-ROM 
    ¤CD-R/RW Drive ¤DVD+/-R/RW Drive 
    ¤DVD-ROM 
     
     
     Computer Case  
    ¤Cases (Computer cases, ATX Form) ¤Cases (Server Rackmount)  
     
     Computer Systems 
     
    ¤Barebone System ¤Server Barebone Systerms  
     
     Controller & Cards   
     
    ¤PCI Cards ¤SCSI Controller Cards 
    ¤SATA Controller Cards ¤Serial Card 
    ¤Parallel Card ¤All others 
    ¤1394 Card ¤IDE/ATA Cards  
     
     CPU  
     
    ¤Pentium M ¤Intel Pentium 4 
    ¤Intel Xeon ¤Intel Pentium 3 
    ¤Intel Celeron ¤AMD Athlon 64 
    ¤AMD Opteron ¤AMD Athlon MP 
    ¤AMD Athlon XP ¤AMD Duron 
    ¤AMD T-Bird ¤AMD K6-2 
    ¤VIA Cyrix 
     
     
     Data Storage  
     
    ¤Floppy Drive ¤MicroDrive 
    ¤ZIP Drives & Disks ¤Tape Drives & Tapes  
     
     Hard drive   
     
    ¤Serial ATA ¤EIDE 
    ¤SCSI ¤External Hard drive  
     
     Keyboard & Mouse   
     
    ¤PS2/USB Keyboard ¤Wireless Keyboard 
    ¤Gaming - Joystick, Wheels and Game Pad ¤PS2/USB Mouse 
    ¤Wireless Mouse 
     
     
     Memory & Flash Media   
     
    ¤184pin DDR DIMM ¤Server Memory 
    ¤Flash Memory ¤Rambus Memory 
    ¤168pin SDRAM DIMM ¤72-Pin EDO/FPM SIMM  
     
     Monitors, TV & Projectors   
     
    ¤LCD 19 inch ¤LCD 17 inch 
    ¤LCD 15 inch ¤LCD 20.1 inch 
    ¤LCD 18 inch ¤LCD 23 inch 
    ¤LCD 32 inch ¤LCD 24 inch 
    ¤LCD 21.3 inch ¤LCD 20 inch 
    ¤Projectors ¤CRT 15 inch 
    ¤CRT 19 inch ¤CRT 17 inch  
     
     Motherboard   
     
    ¤For AMD ¤For Intel 
    ¤For Server System 
     
     
     Mp3 Players   
     
    ¤512 MB ¤128 MB 
    ¤256 MB ¤40 GB 
    ¤64 MB 
     
     
     Network Devices   
     
    ¤Modems ¤Wireless AP/Bridge 
    ¤Network Cards ¤KVM (Keyboard, Video, Mouse) Switches 
    ¤Print Server ¤Network Servers 
    ¤Routers/Remotes ¤Wireles Routers 
    ¤Switches ¤Hubs - Network / USB / Firewire  
     
     Power   
     
    ¤400-599 Watts ¤200-399 Watts 
    ¤UPS ¤600-More 
    ¤60-199 Watts 
     
     
     Printer & Scanner   
     
    ¤Inkjet printer ¤Scanners 
    ¤All in One ¤Laser printer 
    ¤Photo printer 
     
     
     Sound card   
     
    ¤7.1CH ¤6.1/7CH 
    ¤5.1/6CH ¤4.1/5CH 
    ¤4 CH 
     
     
     Speaker   
     
    ¤2.0 ¤2.1 
    ¤5.1 ¤Headphones, Headsets and Accessories 
    ¤7.1CH ¤4.1 
    ¤6.1 
     
     
     USB drive   
     
    ¤4 GB ¤512 MB 
    ¤2 GB ¤1GB 
    ¤256 MB ¤128 MB 
    ¤64 MB ¤32 MB 
    ¤16 MB 
     
     
     Video card   
     
    ¤64 MB ¤128 MB 
    ¤256 MB ¤512 MB 
    ¤32 MB ¤16 MB 
    ¤8 MB ¤TV Tuners  
     
     Network Devices   
     
    ¤Wireless Adapters 
     
     
     
      
      
     Software  
     
     Windows 
      
     
    ¤Operation System ¤application software  
     
     Digital Cameras  
     
     Accessories   
     
    ¤Digital Camera Batteries & Chargers ¤Digital Camera Docks 
    ¤Digital Camera Kits 
     
     
     Camcorder   
     
    ¤Camcorders - Analog/Digital 
     
     
     Digital Cameras  
     
    ¤4.0 MegaPixel ¤3.2 MegaPixel 
    ¤3.0 MegaPixel ¤3.1 MegaPixel 
    ¤2.0 MegaPixel ¤1.3 MegaPixel 
    ¤3.34 MegaPixels ¤4.23 MegaPixel 
    ¤5.0 MegaPixel ¤8.0 MegaPixel 
    ¤6.0 MegaPixel 
     
     
     WebCam   
     
    ¤WebCam 
     
     
     
      
      
     Notebooks, Mini Computers, and PDAs  
     
     Accessories   
     
    ¤Battery ¤others 
    ¤Carry Bag 
     
     
     Notebook Parts 
     
    ¤Memory (Notebook Memory) ¤Barebone System 
    ¤Hard Drives - Notebooks/Laptops ¤PC Cards/PCMCIA Modem and Network Devices 
    ¤Floppy Drives ¤CD/DVD ROM/RW Drives  
     
     Notebooks   
     
    ¤Inter CPU 
     
     
     PDAs  
     
    ¤PDA 
      

  19.   

    Computer Hardware 、Software、Notebooks、Digital Cameras、 Mini Computers, and PDAs这四个是Catalog 大类。
    Accessories 、Network Devices 、CD DVD Rom/R/RW....是每个Catalog 大类里的sorts类。
    ¤Surge Suppressors ¤Accessories - CPU 
    ¤Fans & Thermal Controllers ¤Card Reader/Adapter 
    ¤Cables ¤Accessories - Hard Drive 
    ¤Accessories - Video Card ¤Accessories-Printer 
    ¤Accessories - USB ¤Accessories - Case 
    ¤Digital Media Remote 这些是sorts类里的smlcatalog了。
    以此类推
    然后,我要的是都按字母的顺序排列