• [B] Best SQL Condition Sort

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • It's not the true 'BEST'. The 'Best sort' means you just need to sort the column names by lexicographic order ascending.

    You're given an SQL command only in the format of 'SELECT blabla... FROM blabla... WHERE blabla...', and you have to sort the 'blabla...' in lexicographic order ascending.

    The format is like that:

    1. There's a space after 'SELECT'. ('SELECT' will only be uppercase)

    2. If there're several column names after 'SELECT', it will follows a ',' and a space after each column name but the last one. Like 'name, id'.

    3. There's a space after 'FROM'. ('FROM' will only be uppercase)

    4. If there're several column names after 'FROM', it will follows a ',' and a space after each column name but the last one. Like 'name, id'.

    5. The condition will only contain the operator '=' and logic words 'AND'(uppercase).

    6. There're spaces at the two sides of '='.

    7. The const that at the right side of '=' will only be integer or string. The string will surrounded by '.

    8. The column names and table names will only be lowercase.

    9. There're 3 position (signed by '*') at 'SELECT * FROM * WHERE *', each position will contain at most 50 items. Each item name in its own position is unique. For the items after 'WHERE', your sort key is only the column name.

    10. The length of each item will no more than 20. The length of const at the right side of '=' will no more than 20.

    It's like that: SELECT a, b FROM c, d WHERE a = 'A' AND b = 5

  • 输入
  • Several SQL command. Each SQL command per line.
  • 输出
  • For each command, you should output them after sorting.
  • 样例输入
  • SELECT name, id, a FROM tel, stu WHERE tel = '1' AND id = 5
    
  • 样例输出
  • SELECT a, id, name FROM stu, tel WHERE id = 5 AND tel = '1'
    
  • 提示
  • 来源
  • XadillaX
  • 操作

显示春菜