rendered paste bodymysql> describe stockinvoice;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| supplierid | int(11) | | | 0 | |
| invoice | varchar(255) | | | | |
| gst | float | | | 0 | |
| shipping | float | | | 0 | |
| date | int(11) | | | 0 | |
+------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
mysql> describe stockinvoiceitems;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | NULL | auto_increment |
| invid | int(11) | | | 0 | |
| partid | int(11) | | | 0 | |
| supplierpart | varchar(255) | | | | |
| quantity | int(11) | | | 0 | |
| cost | float | | | 0 | |
+--------------+--------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
mysql> select invid from stockinvoiceitems where partid='1';
+-------+
| invid |
+-------+
| 31 |
+-------+
1 row in set (0.00 sec)
mysql> select * from stockinvoice where id IN ('31','32');
+----+------------+---------+-------+----------+------------+
| id | supplierid | invoice | gst | shipping | date |
+----+------------+---------+-------+----------+------------+
| 31 | 323 | 255320 | 60.86 | 10 | 1121313600 |
| 32 | 319 | 1160967 | 42.37 | 33.32 | 1122264000 |
+----+------------+---------+-------+----------+------------+
2 rows in set (0.07 sec)
mysql> select * from stockinvoice where id IN (SELECT invid FROM stockinvoiceitems WHERE partid='1');
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT invid FROM stockinvoiceitems WHERE partid='1')' at line