0

So I have two databases that have separate pieces of information that I need together. Instead of running queries on each database I was told that I can join the two databases together so that I can declare variables from both databases without worrying about which database was specified or what not. Here's what I have so far

$query = "select * from quotes WHERE qSymbol='{$strSymbol}' ORDER BY qQuoteDateTime DESC LIMIT 15";

I want to have all fields in the quotes database as well as all database in the symbols database to be accessible without having to specifically call each database. How can I add on to this code to let me do that?

Thank you all!

4
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

Okay so what is wrong with this then? I keep getting "invalid" as a result..

$query = "SELECT symSymbol, symName, symMarketCap, qSymbol, qQuoteDateTime, qLastSalePrice, qNetChangePrice, qNetChangePct, qTodaysHight, qTodaysLow"
			."qShareVolumeQty, qPreviousClosePrice, qBidPrice, qAskPrice, q52WeekHigh, q52WeekLow, qCashDividendAmount, qEarningsPerShare, qCurrentPERatio"
			."qCurrentYieldPct, qTotalOutstandings FROM symbols LEFT JOIN quotes ON symSymbol=qSymbol WHERE symSymbol='{$strSymbol}' ORDER BY qQuoteDateTime"
			."LIMIT 10";

	$result = @$db->query($query);

	if(!$result)
	{
		print "Invalid";
	}
	else
	{
		$row = @$result->fetch_assoc();
		extract($row);
	}
0

if you have phpmyadmin then , get output your query using echo, then copy that query to phpmyadmin, and run. see what error you are getting there.

.
.
.
$query="SELECT symSymbol,................. LIMIT 10";

echo $query;

$result = @$db->query($query);
.
.
.
.
0

You forget two commas in field selection after qTodaysLow and qCurrentPERatio shown in red color.
Give space after qQuoteDateTime.

$query = "SELECT symSymbol, symName, symMarketCap, qSymbol, qQuoteDateTime, qLastSalePrice, qNetChangePrice, qNetChangePct, qTodaysHight, qTodaysLow, "
			."qShareVolumeQty, qPreviousClosePrice, qBidPrice, qAskPrice, q52WeekHigh, q52WeekLow, qCashDividendAmount, qEarningsPerShare, qCurrentPERatio, "
			."qCurrentYieldPct, qTotalOutstandings FROM symbols 
			LEFT JOIN quotes ON symSymbol=qSymbol 
			WHERE symSymbol='{$strSymbol}' 
			ORDER BY qQuoteDateTime "
			."LIMIT 10";

Edited by vibhaJ: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.