MySQL IF() ফাংশনের প্রথম আর্গুমেন্ট হিসাবে একটি SELECT স্টেটমেন্ট ব্যবহার করা বেশ সম্ভব। এটি বোঝার জন্য, টেবিল 'ছাত্রদের' থেকে নিম্নরূপ ডেটা বিবেচনা করুন।
mysql> Select * from Students; +----+-----------+-----------+----------+----------------+ | id | Name | Country | Language | Course | +----+-----------+-----------+----------+----------------+ | 1 | Francis | UK | English | Literature | | 2 | Rick | USA | English | History | | 3 | Correy | USA | English | Computers | | 4 | Shane | France | French | Computers | | 5 | Validimir | Russia | Russian | Computers | | 6 | Steve | Australia | English | Geoinformatics | | 7 | Rahul | India | Hindi | Yoga | | 8 | Harshit | India | Hindi | Computers | | 9 | Harry | NZ | English | Electronics | +----+-----------+-----------+----------+----------------+ 9 rows in set (0.00 sec)
এখন নিম্নলিখিত ক্যোয়ারীটি IF() ফাংশনের মধ্যে SELECT স্টেটমেন্ট ব্যবহার করবে
mysql> Select ID, IF((Select COUNT(*) FROM Students WHERE Language = 'English')>(Select COUNT(*) from Students WHERE Language <> 'English'),(CONCAT("Name is ", Name)),(CONCAT("Course is ", Course))) AS 'Name/Course' from Students; +----+-------------------+ | ID | Name/Course | +----+-------------------+ | 1 | Name is Francis | | 2 | Name is Rick | | 3 | Name is Correy | | 4 | Name is Shane | | 5 | Name is Validimir | | 6 | Name is Steve | | 7 | Name is Rahul | | 8 | Name is Harshit | | 9 | Name is Harry | +----+-------------------+ 9 rows in set (0.00 sec)