Skip to content
Advertisement

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 PN001 Chicago 7 PN001 ChicagoHold 0 PN002 Atlanta 5 PN002 AtlantaHold 18 PN002

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 userA and userB

MySQL Circular References in One-to-Many Relation: Is there a way to avoid it?

Consider following as an example: I have a User table which contains user’s information along with a PrimaryAddress column that references Address table. The Address table, contains address information along with a UserId column which refers to who the address belongs to. Each user can have many addresses, but only one address can be PrimaryAddress. Therefore, the User table needs

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 editUser 6 UserManagement index Roles_Permissions: Roles Permissions 1

Can a backticked identifier have a backtick in it?

Is it possible to escape a SQL identifier in either MySQL or BigQuery or any other RDBMS that allows quoting of identifiers with the ` character? For example: Works, but then How would I add a literal backtick to it, or is that just not allowed? Answer Yes. Use a doubled backtick, eg: This is similar syntax for including quotes

Advertisement