Skip to content

Tag: mysql

SQL multirow data on one row

I almost never ask a question, so please be patient with me. Example Orders table: Order_ID Ord_Partno Ord_UnitPrice Ord_Qty 1658712 PN001 $1.20 9 1658712 PN002 $2.40 4 1658712 PN003 $1.40 21 1658712 PN004 $1.10 16 Example Inventory table: Inv_Partno Inv_Warehouse Stock PN001 Atlanta 14 PN001 AtlantaHold 0 PN…

Is it possible to use result or state of query in same query

For example I have this table events: user_id event_type date_of_event userA X 01-01-2000 userA Y 01-01-2005 userB X 01-01-2000 userB Y 01-01-2100 I want to select all users that have an event_type = X but no event_type Y in the next 2 years AFTER the date of event_type X. So in the table above that would be …

INSERT INTO query WITH RECURSIVE query

I have created a WITH RECURSIVE function and would like to use it with an INSERT INTO function so that the results insert into the path column. category_id category_name parent_id path 1 Root 0 2 Fishing 1 3 Sea 2 4 Lures 3 7 Coarse 2 8 Lures 7 9 Fly 2 I have tried the following code but the

Check all possible connection exists

I want to check for all connections between two table exists and return all rows specifying weather the connections exists or not for example here is my tables: Permissions: index Controller Action 5 Error index 2 Home index 3 Home login 4 Home logout 1 Test index 9 UserManagement createUser 8 UserManagement …