Ich möchte alle Tabellen beitreten, in allen Tabellen sind alle Spaltennamen gleich. Meine Frage ist unten. Bitte helfen Sie mir, die Daten zu holen.
Meine Tabellenstruktur CREATE TABLE IF NOT play_school
( token_id
varchar (255) NOT NULL, id
int (11) NOT NULL AUTO_INCREMENT VORHANDEN, ad_id
varchar (255) NOT NULL, title
Text NOT NULL, category
varchar (255) NOT NULL, name
Text NOT NULL, image
varchar (255) NOT NULL, content
Text NOT NULL, offer
Text NOT NULL, note
Text NOT NULL, price
varchar (255) NOT NULL, address
varchar (255) NOT NULL, contact_no
Text NOT NULL, email_id
Text NOT NULL, timestamp
Datum NOT NULL, status
varchar (255) NOT NULL, PRIMARY KEY (id
), UNIQUE KEY token_id
(token_id
), UNIQUE KEY token_id_2
(token_id
) ) ENGINE = InnoDB DEFAULT CHARSET = latin1 AUTO_INCREMENT = 49;Tabelle Join in PHP mysql
Alle Tabellen Struktur sind gleich für car_showroom, Coaching, elektronische .... wie play_school Tabelle, in allen Tabellen ad_id = 'xyz' sind die gleichen und die get-ID ist auch 'xyz'.now ich möchte Daten abrufen Alle Tabellen mit ad_id = 'xyz'. Diese Abfrage wird ohne Fehler ausgeführt. aber die Daten nicht abgeholt.
$email_id = $_GET['id'];
$result = $con->prepare("SELECT * FROM bike_showroom
JOIN car_showroom
JOIN coaching
JOIN college
JOIN electronic
JOIN furniture_showroom
JOIN hospital
JOIN job
JOIN mobile_shop
JOIN pets_shops
JOIN play_school
JOIN real_estate
JOIN services
JOIN shopping_store
JOIN stationary_shops
JOIN sweet_shop
WHERE bike_showroom.ad_id = '".$email_id.
"' AND car_showroom.ad_id = '".$email_id.
"' AND coaching.ad_id = '".$email_id.
"' AND college.ad_id = '".$email_id.
"' AND electronic.ad_id = '".$email_id.
"' AND furniture_showroom.ad_id = '".$email_id.
"' AND hospital.ad_id = '".$email_id.
"' AND job.ad_id = '".$email_id.
"' AND mobile_shop.ad_id = '".$email_id.
"' AND pets_shops.ad_id = '".$email_id.
"' AND play_school.ad_id = '".$email_id.
"' AND real_estate.ad_id = '".$email_id.
"' AND services.ad_id = '".$email_id.
"' AND shopping_store.ad_id = '".$email_id.
"' AND stationary_shops.ad_id = '".$email_id.
"' AND sweet_shop.ad_id = '".$email_id."' ");
$result->execute();
$row = $result->fetch();
for($i=0; $row = $result->fetch(); $i++){
echo $row['title'];
}
Sie müssen eine gemeinsame Beziehung zwischen den Tabellen und JOIN auf denen finden. Es funktioniert auch in diesem Fall nicht, es sei denn, es gibt eine Zeile in jeder Tabelle mit dieser $ email_id. Sie müssen wahrscheinlich Ihren Ansatz überdenken. Im Allgemeinen möchten Sie nicht mehr als ein paar Tische gleichzeitig verbinden. – Cfreak
Nun, funktioniert es? Fast funktioniert? Überhaupt nicht funktioniert? Gibt es Fehlerprotokolle? Was ist die erwartete Ausgabe? Wie können wir helfen, wenn wir nicht wissen, was das Problem ist? – crizzis
Auch Ihre Abfrage ist anfällig für SQL-Injection. Sie möchten das definitiv beheben. Sie können darüber lesen, was es ist und wie es hier zu beheben ist: http://bobby-tables.com/ – Cfreak