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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현