Hello to all! :-)
I want to make a choice from several tables at the same time on the 'namber' line (the number of tables is 22, there are 4 columns in each table (id, namber, name, text).
I decided to make a UNION request, but I don’t know whether to make the request correctly or is there another more convenient and faster way?
$namber = $_GET['namber']; require 'lib/connect.php'; $strSQL = " SELECT * FROM `g_fight` WHERE namber='$namber' UNION SELECT * FROM `g_drive` WHERE namber='$namber' UNION SELECT * FROM `g_strategy` WHERE namber='$namber' UNION SELECT * FROM `g_arcade` WHERE namber='$namber' UNION SELECT * FROM `g_azart` WHERE namber='$namber' UNION SELECT * FROM `g_cart` WHERE namber='$namber' UNION SELECT * FROM `g_classical` WHERE namber='$namber' UNION SELECT * FROM `g_headcrash` WHERE namber='$namber' UNION SELECT * FROM `g_history` WHERE namber='$namber' UNION SELECT * FROM `g_interesting` WHERE namber='$namber' UNION SELECT * FROM `g_kids` WHERE namber='$namber' UNION SELECT * FROM `g_kidsschook` WHERE namber='$namber' UNION SELECT * FROM `g_line` WHERE namber='$namber' UNION SELECT * FROM `g_logical` WHERE namber='$namber' UNION SELECT * FROM `g_pazzle` WHERE namber='$namber' UNION SELECT * FROM `g_shoot` WHERE namber='$namber' UNION SELECT * FROM `g_snake` WHERE namber='$namber' UNION SELECT * FROM `g_spaceship` WHERE namber='$namber' UNION SELECT * FROM `g_sport` WHERE namber='$namber' UNION SELECT * FROM `g_walking` WHERE namber='$namber' UNION SELECT * FROM `g_tetris` WHERE namber='$namber' UNION SELECT * FROM `g_rolier` WHERE namber='$namber' UNION SELECT * FROM `g_ontable` WHERE namber='$namber'"; $rs = mysql_query($strSQL); while($row = mysql_fetch_array($rs)) { $str = "".$row['name'].""; $NAME = str_replace(" ","",$str); $gtype="Игра";// тип (для закладки) $text="".$row['text']."";//описание mysql_close(); }
unionwithunion allit is faster. And so, you have no other way to go with such a database structure. A more privileged decision would be to make one common table, possibly with a "game type" column. Although it is more like the genres of games and one game may have several. then the table of games, the table of genres and the link id_gry-id_gangr come to the fore - Mike