I have
tbl 1 id_column(1 2 3 )
tbl 2 id_column(1 1 1 2 2 3 3 3)

I need result tbl2 join with tbl 1 values (3 3 3)

Thank you in advance i'm strugling from two days for this.

Recommended Answers

All 18 Replies

SELECT * FROM table1, table2
WHERE table1.id = table2.id

SELECT * FROM table1
LEFT JOIN table2
ON table1.id = table2.id
SELECT * FROM table1, table2
WHERE table1.id = table2.id

SELECT * FROM table1
LEFT JOIN table2
ON table1.id = table2.id

Hellow again pritaes.
It not so simple I have the condition to select the bigest value from first table
how can i say order desc limit 1 without error?

Hellow again pritaes.
It not so simple I have the condition to select the bigest value from first table
how can i say order desc limit 1 without error?

the first table sum the rows from the second by some criteria. Now I wish to join them together to se the first table results with the second table details about the result in the first one.

the first table sum the rows from the second by some criteria. Now I wish to join them together to se the first table results with the second table details about the result in the first one.

I made more tables with result and now I wish to create a sword off report that show echo the detail order and the sum of orders

the data I present hold the foreigner key

Can you give a visual example of what you have, and what you want to output ? I'm not really sure what to do yet.

I think this is more clear
I wish to show the order total sum from the first table with the detail of order from the second table by the corespondent foreigner key
first table second table
id_f sumofvalu id_s id_f value
1 15 1 1 10
2 10 2 1 5
3 2 5
4 2 5

first table
id_proiect Values
1 15
2 10
3 5
second table

id_proiect primarikey Values
1 1 5
1 2 5
1 3 5
2 4 6
2 5 4
3 6 5

SELECT * FROM table2
LEFT JOIN table1
ON table2.id_project = table1.id_project

here is more clear

first table		
id_proiect	Values	
1	          15	
2	           10	
3	           5	
second table		
		
id_proiect	primarikey	Values
1	                1	5
1	                2	5
1	                3	5
2	                4	6
2	                5	4
3	6	5

I tried that but it not the result corect
I wish to create sword of report with grand total , subtotal 1, subtotal2 and order detail. I have tables readi for each subtotal but I do not know how to put it all togheter on one page and with related data . Thank you for your time I really apreciate

Show a table like this with your desired output, perhaps that will clarify things.

first table		
id_proiect	Values	
1	         15	
2	         10
3	          5	
second table		
		
id_proiect	primarikey	Values
1	                1	5
1	                2	5
1	                3	5
2	                4	6
2	                5	4
3	6	5

I wish to create sword of report with grand total , subtotal 1, subtotal2 and order detail. I have tables readi for each subtotal but I do not know how to put it all togheter on one page and with related data . Thank you for your time I really apreciate

Result table

primarikey	Values
         1	5
         2	5
         3	5
[B]Total idproiect1	15[/B]
        4	6
        5	4
[B]Total idproiect2	10[/B]
        6	5
Total idproiect3	5
[B]Grand total 1+2+3	30[/B]

My head split in half

My query will give you the data. You just want a specific output, which cannot be done with a single query. What are you using to output the report, PHP ?

(I just saw you already got some useful queries in the mysql forum, excellent.)

Yes and I already have create 3,4 related table with totals and grand total but I don't know how to echo it

This is a problem for php and mysql, I have in several tables related like a tree by key and foreign columns with total. Now I try to echo on the index page a report that choose total from table 2 ,the field that gave the totalsum for table1, and the Grand total in table 1.
HOW TO CONECT GRAND TOTAL FROM TABLE 1 WITH THE SUBTOTALS IN TABLE 2?

Example of GRAND TOTAL, TOTAL1 TOTAL2 TOTAL 3 SUBTOTAL 1, SUBTOTAL 2 SUBTOTAL 3
How many chairs we have in our village?
Grand total chairs in houses =total chair in house A + total chair in house B
Total chair in house A = TOTAL CHAIR IN ROOM 1 + TOTAL CHAIR IN ROOM 2
TOTAL CHAIR IN ROOM1 = SUBTOTAL FOR REED CHAIR + SUBTOTAL FOR GREEN CHAIR
TOTAL CHAIR IN ROOM 2 = SUBTOTAL FOR REED CHAIR + SUBTOTAL FOR GREEN CHAIR
---------<AND SO ON FOR HOUSE B ----->---------------------------------------------------------------------------------------I have the totals each one in his own table with his own id I wish to echo them by needs in one final report
Detailed report with chair by color, for each room or village or house
Detailed report with house by nr of chairs in it for each house

I have tables with totals for each group. now I nedd to put them toghether by diferent criteria, please say you know how to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.