Mysql
 sql >> डेटाबेस >  >> RDS >> Mysql

एकाधिक अद्वितीय MySQL तालिकाओं को संयोजित करें और एक कॉलम द्वारा ऑर्डर करें

इसे आजमाएं:

SELECT * from (
SELECT banned as Punisher, banned_by as Punished, ban_reason as Reason, ban_expires_on  as Expire, ban_time as Date  FROM mb_bans 
UNION
SELECT kicked as Punisher, kicked_by as Punished, kick_reason as Reason, NULL  as Expire, kick_time as Date FROM mb_kicks 
UNION
SELECT muted as Punisher, muted_by as Punished, mute_reason as Reason, mute_expires_on  as Expire, mute_time as Date  FROM mb_mutes 
UNION
SELECT warned as Punisher, warned_by as Punished, warn_reason as Reason, NULL  as Expire,  warn_time as Date FROM mb_warnings
) d order by d.Date DESC;

संपादित करें

मैं किस प्रकार का रिकॉर्ड प्राप्त कर सकता हूं? (आईई। क्या लौटा हुआ परिणाम बैन टेबल, म्यूट टेबल, किक्स टेबल आदि से है।)

SELECT * from (
    SELECT banned as Punisher, banned_by as Punished, ban_reason as Reason, ban_expires_on  as Expire, 'ban' as TableType, ban_time as Date  FROM mb_bans 
    UNION
    SELECT kicked as Punisher, kicked_by as Punished, kick_reason as Reason, NULL  as Expire, 'kick' as TableType, kick_time as Date FROM mb_kicks 
    UNION
    SELECT muted as Punisher, muted_by as Punished, mute_reason as Reason, mute_expires_on  as Expire, 'mute' as TableType, mute_time as Date  FROM mb_mutes 
    UNION
    SELECT warned as Punisher, warned_by as Punished, warn_reason as Reason, NULL  as Expire,  'warn' as TableType, warn_time as Date FROM mb_warnings
    ) d order by d.Date DESC;


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. मैं एक mysql कथन को पूर्ववत कैसे कर सकता हूं जिसे मैंने अभी निष्पादित किया है?

  2. MySQL में CAST का उपयोग करते समय मुझे सिंटैक्स त्रुटि क्यों मिलती है?

  3. Mysql2 मणि ​​स्थापित नहीं कर सकता

  4. mysql बाइनरी तुलना इंडेक्स का उपयोग नहीं करती है

  5. $_POST चर $_FILES और मल्टीपार्ट/फॉर्म-डेटा के साथ काम नहीं कर रहे हैं