我正在以10美元的成績獲得研究所。但是我希望獲得具有GATE課程名稱的研究所。我怎樣才能做到這一點? course_records在學院有一個外鍵院校ID。我無法加入這些表格。 任何形式的幫助將不勝感激。使用外鍵加入表格
$result=$conn->query("SELECT *, (6371 * acos(cos(radians($user_latitude)) * cos(radians(latitude)) * cos(radians(longitude) - radians($user_longitude)) + sin(radians($user_latitude)) * sin(radians(latitude)))) AS distance FROM institutes HAVING distance < 10 ORDER BY distance LIMIT 0 , 10 ");
mysql> select * from institutes;
+--------------+-------------------+---------------------+----------------+----------------------------------+-------------+--------+----------+-----------+
| institute_id | name | email | contact_number | address | telephone | tut_id | latitude | longitude |
+--------------+-------------------+---------------------+----------------+----------------------------------+-------------+--------+----------+-----------+
| 23 | Dhananjay Classes | [email protected] | 9999888877 | Palam dabri Road,Mahavir Enclave | 011-1234567 | 11 | 28.5892 | 77.0858 |
| 24 | ffe | [email protected] | 323232 | | | 11 | 28.5667 | 77.2833 |
+--------------+-------------------+---------------------+----------------+----------------------------------+-------------+--------+----------+-----------+
mysql> select * from course_records;
+-----------+------+--------------+-------+--------------+--------------------------+--------------------+---------------+-----------+---------+--------------+
| course_id | name | subject | fees | num_students | num_students_per_teacher | month_of_admission | num_of_trials | commision | created | institute_id |
+-----------+------+--------------+-------+--------------+--------------------------+--------------------+---------------+-----------+---------+--------------+
| 1 | GATE | CSE | 10000 | 110 | 20 | January | 3 | yes | NULL | 23 |
| 2 | NDA | all_subjects | 7000 | 50 | 20 | April | 3 | yes | NULL | 23 |
| 3 | 12th | Math | 2 | 90 | 20 | | 2 | | NULL | 23 |
+-----------+------+--------------+-------+--------------+--------------------------+--------------------+---------------+-----------+---------+--------------+
加入逗號後代碼工作'SELECT i.name as inst_name,cr.name as course_name' – tarun14110
哦,是的,讓我更新我的答案 –