Link to home
Start Free TrialLog in
Avatar of asaidi
asaidi

asked on

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
Avatar of ralmada
ralmada
Flag of Canada image

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

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

Avatar of asaidi
asaidi

ASKER

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";
ASKER CERTIFIED SOLUTION
Avatar of ralmada
ralmada
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of asaidi

ASKER

Hi
thanks for your time but still empty result..
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).
Avatar of asaidi

ASKER

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