Mysql query - Count the founded rows on joined table [closed]Can I concatenate multiple MySQL rows into one field?How to output MySQL query results in CSV format?Convert HTML + CSS to PDF with PHP?Secure hash and salt for PHP passwordsMySQL - Get row number on selectJoin vs. sub-queryReference — What does this symbol mean in PHP?Insert into a MySQL table or update if existsHow to get the sizes of the tables of a MySQL database?Reference - What does this error mean in PHP?

Inconsistent behavior of compiler optimization of unused string

Is it possible to 'live off the sea'

How to officially communicate to a non-responsive colleague?

Are there downsides to using std::string as a buffer?

What are the peak hours for public transportation in Paris?

Trapping Rain Water

How do you show, through your narration, a hard and uncaring world?

How to retract an idea already pitched to an employer?

What language is the software written in on the ISS?

Where does "0 packages can be updated." come from?

Soft question: Examples where lack of mathematical rigour cause security breaches?

Should an arbiter claim draw at a K+R vs K+R endgame?

Does an ice chest packed full of frozen food need ice?

Arriving at the same result with the opposite hypotheses

How did they achieve the Gunslinger's shining eye effect in Westworld?

What can plausibly explain many of my very long and low-tech bridges?

Hottest Possible Hydrogen-Fusing Stars

Is the term 'open source' a trademark?

Using "subway" as name for London Underground?

Confusion about off peak timings of London trains

Was Jesus good at singing?

Was the output of the C64 SID chip 8 bit sound?

What's up with this leaf?

Should I give professor gift at the beginning of my PhD?



Mysql query - Count the founded rows on joined table [closed]


Can I concatenate multiple MySQL rows into one field?How to output MySQL query results in CSV format?Convert HTML + CSS to PDF with PHP?Secure hash and salt for PHP passwordsMySQL - Get row number on selectJoin vs. sub-queryReference — What does this symbol mean in PHP?Insert into a MySQL table or update if existsHow to get the sizes of the tables of a MySQL database?Reference - What does this error mean in PHP?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-5















I have two tables



First one: Offers



id
user_id
user_data



The second one: Orders



id
user_id



order_data



Now, the goal is, to get the list of the OFFERS including the count of the orders table, where orders.user_id == offers.user_id



the result must be:



id
user_id
orders_count




Thank you in advance!










share|improve this question













closed as too broad by Strawberry, Cindy Meister, Sterling Archer, Henry Woody, Alain Merigot Mar 24 at 22:51


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    Right, and what did you try?

    – Utkanos
    Mar 24 at 16:12











  • blog.codinghorror.com/a-visual-explanation-of-sql-joins

    – Vickel
    Mar 24 at 16:15

















-5















I have two tables



First one: Offers



id
user_id
user_data



The second one: Orders



id
user_id



order_data



Now, the goal is, to get the list of the OFFERS including the count of the orders table, where orders.user_id == offers.user_id



the result must be:



id
user_id
orders_count




Thank you in advance!










share|improve this question













closed as too broad by Strawberry, Cindy Meister, Sterling Archer, Henry Woody, Alain Merigot Mar 24 at 22:51


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    Right, and what did you try?

    – Utkanos
    Mar 24 at 16:12











  • blog.codinghorror.com/a-visual-explanation-of-sql-joins

    – Vickel
    Mar 24 at 16:15













-5












-5








-5








I have two tables



First one: Offers



id
user_id
user_data



The second one: Orders



id
user_id



order_data



Now, the goal is, to get the list of the OFFERS including the count of the orders table, where orders.user_id == offers.user_id



the result must be:



id
user_id
orders_count




Thank you in advance!










share|improve this question














I have two tables



First one: Offers



id
user_id
user_data



The second one: Orders



id
user_id



order_data



Now, the goal is, to get the list of the OFFERS including the count of the orders table, where orders.user_id == offers.user_id



the result must be:



id
user_id
orders_count




Thank you in advance!







php mysql codeigniter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 16:11









ArmnatureArmnature

1




1




closed as too broad by Strawberry, Cindy Meister, Sterling Archer, Henry Woody, Alain Merigot Mar 24 at 22:51


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as too broad by Strawberry, Cindy Meister, Sterling Archer, Henry Woody, Alain Merigot Mar 24 at 22:51


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1





    Right, and what did you try?

    – Utkanos
    Mar 24 at 16:12











  • blog.codinghorror.com/a-visual-explanation-of-sql-joins

    – Vickel
    Mar 24 at 16:15












  • 1





    Right, and what did you try?

    – Utkanos
    Mar 24 at 16:12











  • blog.codinghorror.com/a-visual-explanation-of-sql-joins

    – Vickel
    Mar 24 at 16:15







1




1





Right, and what did you try?

– Utkanos
Mar 24 at 16:12





Right, and what did you try?

– Utkanos
Mar 24 at 16:12













blog.codinghorror.com/a-visual-explanation-of-sql-joins

– Vickel
Mar 24 at 16:15





blog.codinghorror.com/a-visual-explanation-of-sql-joins

– Vickel
Mar 24 at 16:15












1 Answer
1






active

oldest

votes


















1














You have all the ingredients, it sounds like you just need to write the SQL. It would probably be something like:



select
a.id, a.user_id, count(*)
from offers a
inner join orders b on
a.user_id = b.user_id
group by a.id, a.user_id;





share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You have all the ingredients, it sounds like you just need to write the SQL. It would probably be something like:



    select
    a.id, a.user_id, count(*)
    from offers a
    inner join orders b on
    a.user_id = b.user_id
    group by a.id, a.user_id;





    share|improve this answer



























      1














      You have all the ingredients, it sounds like you just need to write the SQL. It would probably be something like:



      select
      a.id, a.user_id, count(*)
      from offers a
      inner join orders b on
      a.user_id = b.user_id
      group by a.id, a.user_id;





      share|improve this answer

























        1












        1








        1







        You have all the ingredients, it sounds like you just need to write the SQL. It would probably be something like:



        select
        a.id, a.user_id, count(*)
        from offers a
        inner join orders b on
        a.user_id = b.user_id
        group by a.id, a.user_id;





        share|improve this answer













        You have all the ingredients, it sounds like you just need to write the SQL. It would probably be something like:



        select
        a.id, a.user_id, count(*)
        from offers a
        inner join orders b on
        a.user_id = b.user_id
        group by a.id, a.user_id;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 16:59









        andyandy

        464




        464















            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript