Jump to content

How to say this


manalnor

Recommended Posts

Hello friends,

 

it is very complicated and spent alot of time thinking and i can not do it

 

let say we have 2 tables

 

Table1 (id,user,code) example

 

(1,user1,code1)

(2,user1,code2)

(3,user2,code3)

(4,user3,code4)

 

this means user1 has added code1 and code2

 

Table2 (id,code,hits) example

 

(1,code1,100)

(2,code2,50)

(3,code3,40)

(4,code4,80)

 

this means code1 has 100 hits and code2 has 50 hits

 

I wanna get [ the sum of hits of codes that added by only user1 ] it will be 100+50=150 Hits

 

i've an idea

1- query for all codes added by user1 at table 1

and keep the results as array and it should be (code1,code2)

 

2- then get the sum of hits for all codes in that array (code1,code2) from table 2

 

Now the problem  :shrug: how to say it in MYSQL

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/232169-how-to-say-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.