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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.