transfield Posted May 26, 2006 Share Posted May 26, 2006 Hello,I have 2 tables in 1 database. The table names are developer and developer_log. I want to use the keywords in developer_log to query developer. Then I want to display the results of this query. So here's how it should work:-developer_log.company should query developer.namedeveloper_log.project should query developer.developmentdeveloper_log.property should query developer.typeMy half written code is below. Please help me to modify it. Thank you very much.[code]<?php $username="abc123"; $password="abc123"; $database="abc123"; $host="localhost"; mysql_connect ("$host","$username","$password"); mysql_select_db($database) or die( "Where's the database man?"); $mktime = date('Y-m-d'); $query1=("SELECT * FROM THIS IS WHERE I NEED HELP, I GUESS"); $result1=mysql_query($query1); $num=mysql_num_rows($result1); while ($row1 = mysql_fetch_array($result1)) { echo"<b>Year Approved: </b> ".$row1['year']. "<p><b>Name of Developer: </b> ".$row1['name']. "<p><b>Address: </b> ".$row1['development']. "<p><b>Type of Property: </b> ".$row1['type']. "<p><b>Levels: </b> ".$row1['levels']. "<p><b>Number of Units: </b> ".$row1['quantity']. "<p>" ; } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10515-query-help/ Share on other sites More sharing options...
Barand Posted May 27, 2006 Share Posted May 27, 2006 The non-telepathic amongst us would need to know the structure of those 2 tables so we know which tables contain "levels", "quantity", "year" columns and if you have any selection criteria to extract the particular developer.Knowing stuff like that really does help to construct the query Quote Link to comment https://forums.phpfreaks.com/topic/10515-query-help/#findComment-39563 Share on other sites More sharing options...
poirot Posted May 28, 2006 Share Posted May 28, 2006 ** OFF - TOPIC **Barand you seem to be very good with MySQL and apparently use often MySQL only when I'd use PHP too...How do you UPDATE tables with values retrieved from other tables? JOIN's seem to be usable only in SELECT... Quote Link to comment https://forums.phpfreaks.com/topic/10515-query-help/#findComment-39572 Share on other sites More sharing options...
Barand Posted May 28, 2006 Share Posted May 28, 2006 @poirot[quote]Starting with MySQL Version 4.0.4, you can also perform UPDATE operations that cover multiple tables: UPDATE items,month SET items.price=month.priceWHERE items.id=month.id;The example shows an inner join using the comma operator, but multiple-table UPDATE statements can use any type of join allowed in SELECT statements, such as LEFT JOIN. Note: you cannot use ORDER BY or LIMIT with multiple-table UPDATE. [/quote] Quote Link to comment https://forums.phpfreaks.com/topic/10515-query-help/#findComment-39661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.