napisi normalno upit posto debagiranje tog php-a smara, bice da si tu negde nesto pogresno kucno ... na primer u $pretraga ti se nalazi apostrof i to prsne zato sto ti je mailformed sql .. etc etc ..
dakle napisi upit i pusti ga direktno na mysql cli i vidi dal radi ili ne, to sto ti hoces naravno radi bez problema:
Code:
mysql> drop table if exists a;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> drop table if exists b;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> drop table if exists c;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
mysql> create table a (i int);
Query OK, 0 rows affected (0.01 sec)
mysql> create table b (i int);
Query OK, 0 rows affected (0.00 sec)
mysql> create table c (i int);
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> insert into a values (1), (2), (3), (4), (5);
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into b values (11), (12), (13), (14), (15);
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> insert into c values (21), (22), (23), (24), (25);
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql>
mysql> select * from a;
+------+
| i |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+------+
5 rows in set (0.00 sec)
mysql> select * from b;
+------+
| i |
+------+
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
+------+
5 rows in set (0.00 sec)
mysql> select * from c;
+------+
| i |
+------+
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
+------+
5 rows in set (0.00 sec)
mysql>
mysql> (select * from a) union (select * from b) union (select * from c);
+------+
| i |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
| 21 |
| 22 |
| 23 |
| 24 |
| 25 |
+------+
15 rows in set (0.00 sec)
mysql>
mysql> (select * from a) union (select * from b) union (select * from c) limit 10;
+------+
| i |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 11 |
| 12 |
| 13 |
| 14 |
| 15 |
+------+
10 rows in set (0.00 sec)
mysql> (select * from a) union (select * from b) union (select * from c) limit 2;
+------+
| i |
+------+
| 1 |
| 2 |
+------+
2 rows in set (0.00 sec)
mysql> (select * from a) union (select * from b) union (select * from c) limit 2,7;
+------+
| i |
+------+
| 3 |
| 4 |
| 5 |
| 11 |
| 12 |
| 13 |
| 14 |
+------+
7 rows in set (0.00 sec)
mysql> (select * from a) union (select * from b) union (select * from c) limit 10,2;
+------+
| i |
+------+
| 21 |
| 22 |
+------+
2 rows in set (0.00 sec)
mysql> -- ili komplikovanije
mysql> (select i from a where i>3) union (select i from b where i <15) union (select i from c where i >22);
+------+
| i |
+------+
| 4 |
| 5 |
| 11 |
| 12 |
| 13 |
| 14 |
| 23 |
| 24 |
| 25 |
+------+
9 rows in set (0.00 sec)
mysql> (select i from a where i>3) union (select i from b where i <15) union (select i from c where i >22) limit 3,5;
+------+
| i |
+------+
| 12 |
| 13 |
| 14 |
| 23 |
| 24 |
+------+
5 rows in set (0.00 sec)
mysql>