I have three tables I need to join together. Specifically table 1 needs to join to table 2 and table 2 joins to table 3. I need to return values from table 1 where all instances of the values selected in table 1 in table 2 have a field of some value…
I found this solution online to a HackerRank problem:
SELECT c.hacker_id, h.name, COUNT(c.challenge_id) AS cnt
FROM Hackers AS h
JOIN Challenges AS c ON h.hacker_id = c.hacker_id
GROUP BY c.hacker_id, h.name
HAVING
cnt = (SELECT…
I have three tables
country_table: id int, country_name string
city_table: id int, city_name string, postal_code int, country_id int
customer_table: id int, customer_name string, city_id id, customer_address string
I am looking for an answer which…
this is the continue question from find out time difference for every user in condition mysql 5.7
this is my fiddle
https://dbfiddle.uk/?rdbms=mysql_5.7&fiddle=31b3be9d1e2444eb0b32c262176aa4b4
i have this table
CREATE TABLE test (
ID INT,
…
SELECT
reservationWH.RNUM AS Reservation,
packageWH.PNAME AS "Package Name",
(COUNT(guestWH.CELL_PHONE) * packageWH.COSTPERSON) AS "Total Cost"
FROM
packageWH
INNER JOIN
reservationWH ON packageWH.P_ID = reservationWH.P_ID…
Using the query below, I can search for properties within a given radius and results are returned.
SELECT id, address, ( 3959 * acos( cos( radians( 53.184815 ) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-3.025741) ) + sin(…
I'm trying to fetch the data with HAVING clause.
Here is my code,
//Main Table
$select->from(array('cre' => 'credit'));
//company Table
$select->join(array('com' => 'company), 'cre.account_id = com.account_id');
$select->join(array('u' => 'user'),…
I've got the following table and I'm trying to retrieve every:
name, descr, stock, address, postalcode & the city
where stock of item1 is > 10 AND stock of item2 is > 10 AND stock of item3 > 5
so I don't want the rows that only contain item1 and…
I have three tables that are all inter-related with the following structure.
ModuleCategory Table:
+------------------+----------------+------------+
| ModuleCategoryID | ModuleCategory | RequireAll…
I'm trying to return a list of map items from my DB grouping the items ONLY if the group count is greater than 4 otherwise I don't want the items to be grouped.
My project is built to return all entries within a set area and I'll be using grouping…
So I don't get this error that I keep getting.
select distinct substr(CUSTZIP, 1,5), AVG(CUSTBAL), custcity, custstate
from customer
group by CUSTCITY, custstate
having CUSTSTATE = 'wa' AND avg(CUSTBAL) >100;
The error says "not a GROUP BY…
I have this table
----------------
ID | Duration
----------------
1 10
2 10
3 10
I want to select the id where sum(duration) becomes greater than 15. In other words...
-------------------------
ID |…
I need to select certain fields for a multipart identifier that has duplicates.
I have the query to grab the duplicates correct.
SELECT b.MemEmpID, b.LastName, b.FirstName
FROM table1 As b
GROUP BY b.MemEmpID,…
From reading the MySQL documentation, I can't explain the difference between these two queries in phpMyAdmin:
SELECT * FROM f_ean GROUP BY ean HAVING type = 'media'
--> gives me 57059 results
SELECT ean, type FROM f_ean GROUP BY ean HAVING type =…
I have 3 tabels with the following definitions
people
------
- wid
- name
types
-----
- guid
- type
mapping
-------
- guid
- wid
The people table has the list of people
The types table the type information for each row present in the people…