MySQL टेबल से डेटा एक्सपोर्ट करते समय WHERE क्लॉज में शर्तों का उपयोग किया जा सकता है। इसे एक उदाहरण से समझते हैं।
उदाहरण
मान लें कि Student_info टेबल में निम्नलिखित डेटा है:
mysql> Select * from Student_info; +------+---------+------------+------------+ | id | Name | Address | Subject | +------+---------+------------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Chandigarh | Literature | | 125 | Raman | Shimla | Computers | | 130 | Ram | Jhansi | Computers | | 132 | Shyam | Chandigarh | Economics | | 133 | Mohan | Delhi | Computers | +------+---------+------------+------------+ 6 rows in set (0.07 sec)
यदि हम उन रिकॉर्ड्स को एक्सपोर्ट करना चाहते हैं जिनका id मान 120 से अधिक है, तो निम्न क्वेरी Student_info टेबल से ऐसे रिकॉर्ड्स को Student4.CSV फ़ाइल में एक्सपोर्ट करेगी:
mysql> Select * from student_info WHERE id > 120 into outfile 'C:/mysql/bin/mysql-files/student4.csv' Fields terminated by ','; Query OK, 4 rows affected (0.16 sec)
उपरोक्त क्वेरी निम्नलिखित मानों को Student4.CSV फ़ाइल में एक्सपोर्ट करेगी:
125 Raman Shimla Computers 130 Ram Jhansi Computers 132 Shyam Chandigarh Economics 133 Mohan Delhi Computers