Skip to content
Advertisement

SQL count() not showing values of 0

i just started my journey with SQL, and made some tables of Cyclists, and Cycling Teams. Cyclist’s table contains columns: ID, Name, Team (which is foreign key of TEAMS ID) Team’s table contains columns: ID, Name, Number of Cyclists I want to Count number of Cyclists in each team, by using count() function ( Or basically any function, i just

How to create a trigger on table A that inserts/updates entity in table B?

I have tables TableAAA, TableBBB, TableCCC and TableCollected. The AAA/BBB/CCC tables have a DateTime column: I’d like to have a 1-1 trigger on each table that runs after inserting/updating. It should save the biggest DateTime from given table into the TableCollected table. So if TableAAA table contains 3 rows with dates 1980-01-01, 1990-01-01 and 2010-01-01 then in TableCollected I’d have

Find sum of hours for each date worked

I have a table of timesheet entries set up like this: id job_id employee_id hours_worked date_worked 1 1 111 8 2022-10-01 2 1 222 8 2022-10-01 3 1 222 8 2022-10-02 4 2 222 8 2022-10-03 5 2 111 8 2022-10-04 6 2 222 5 2022-10-05 7 3 111 8 2022-10-04 8 4 333 8 2022-10-07 9 4 111 3

SQL Query to find top item of each group and display details from other tables

I am looking for a query to be able to identify the top-selling items (quantity) per location and to display details about that item and store. My tables are currently organized as such: Stores StoreID Location StoreName 1 San Diego Ralph’s 2 San Francisco Ralph’s 3 Sacramento Ralph’s Products ProductID Name Category 1 Milk Food 2 Eggs Food 3 Reese’s

SQL: difference between where in main body vs join clause

I’m wondering why does the following queries give me a slightly different dataset: So I just moved BETWEEN clause to the main body, logically, it does not matter where to apply it, but the result says it matters. Any suggestions? Thanks! UPD: tried on MySQL 5.6 Answer Maybe it’s hard to answer this question without some images! but I try.

Insert into SQL database from React front end

Im trying to insert some data into a SQL table but Im getting nothing from the front or back end I have tried console.log at various intervals but I cant seem to get data from either side. For reference I have table called products with three columns id, name, image Im trying to insert both name and image with a

Advertisement