select in mysql

Hi
if for example i have this:
$pdf="select account_no,customer_no,unit_serial,pulse_channel,DATE(tran_date)as datei,floor(floor(time_to_sec(tran_date)/900)/4) as txm_hour,
             (floor(time_to_sec(tran_date)/900) % 4)*15 as txm_minutes,sum(unit_qty) as total
             from count_transactions
            WHERE account_no=$acn and customer_no=customer_details.account

can i do what i did in underline..
account-no is for count-transactions table looks for the same customer _details
asaidiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ralmadaCommented:
it seems you want to join both tables. you can try
select 	account_no,
	customer_no,
	unit_serial,
	pulse_channel,
	DATE(tran_date) as datei,
	floor(floor(time_to_sec(tran_date)/900)/4) as txm_hour,
	(floor(time_to_sec(tran_date)/900) % 4)*15 as txm_minutes,
	sum(unit_qty) as total 

from count_transactions, customer_details.account
WHERE count_transactions.account_no=$acn and count_transactions.customer_no=customer_details.account

Open in new window

ralmadaCommented:
oops, like this
select 	account_no,
	customer_no,
	unit_serial,
	pulse_channel,
	DATE(tran_date) as datei,
	floor(floor(time_to_sec(tran_date)/900)/4) as txm_hour,
	(floor(time_to_sec(tran_date)/900) % 4)*15 as txm_minutes,
	sum(unit_qty) as total 

from count_transactions, customer_details
WHERE count_transactions.account_no=$acn and count_transactions.customer_no=customer_details.account

Open in new window

asaidiAuthor Commented:
Hi ralmada
please can you check this if it is correct i cannot get result
$pdf="select c.customer_name,t.account_no,t.customer_no,t.unit_serial,t.pulse_channel,DATE(t.tran_date)as datei,floor(floor(time_to_sec(t.tran_date)/900)/4) as txm_hour,
             (floor(time_to_sec(t.tran_date)/900) % 4)*15 as txm_minutes,sum(t.unit_qty) as total
             from t count_transactions,c customer_details
            WHERE t.account_no=$acn and t.customer_no=c.account and DATE(t.tran_date)>='$date' AND DATE(tran_date)<='$date2'
            AND t.unit_serial=$netw AND t.pulse_channel=1 OR t.pulse_channel=2 OR t.pulse_channel=3 OR t.pulse_channel=4
            group by txm_hour,txm_minutes,datei,c.customer_name,t.account_no ORDER BY txm_hour ASC";
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

ralmadaCommented:
try
select 	customer_name, 
	account_no, 
	customer_no, 
	unit_serial, 
	pulse_channel, 
	datei, 
	tmx_hour, 
	tmx_minutes, 
	sum(t.unit_qty) as total 
from (
	select 
		c.customer_name,
		t.account_no,
		t.customer_no,
		t.unit_serial,
		t.pulse_channel,
		DATE(t.tran_date) as datei,
		floor(floor(time_to_sec(t.tran_date)/900)/4) as txm_hour,
	        (floor(time_to_sec(t.tran_date)/900) % 4)*15 as txm_minutes,
		t.unit_qty
	from count_transactions t,customer_details c
	WHERE 	t.account_no=$acn and 
		t.customer_no=c.account and 
		DATE(t.tran_date)>='$date' AND 
		DATE(tran_date)<='$date2' AND 
		t.unit_serial=$netw AND 
		t.pulse_channel in (1, 2, 3, 4)
) a
group by customer_name, account_no, customer_no, unit_serial, pulse_channel, datei, tmx_hour, tmx_minutes  
ORDER BY txm_hour ASC

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
asaidiAuthor Commented:
Hi
thanks for your time but still empty result..
ralmadaCommented:
what do you mean by "empty result"

Can you provide more information on what are you trying to achieve. Please post some sample data from your tables and the expected result (what you want the query to output).
asaidiAuthor Commented:
empty result means no data displayed
i have an option in my script
when the user choose a customer and when a user choose all the customers
for the customer it is working fine all the calcul is correct but for the second no
please find attached sql data sorry it is a bit big
data.sql
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.