[Solved] How build Query String [closed]

SELECT * FROM YourTableName WHERE bday=’Sun’ AND (branch=”Jamnagar City” OR branch=”Reliance”) SELECT * FROM YourTableName WHERE bday=’Sun’ AND (branch=”Jamnagar City” OR branch=”Reliance” OR branch=”TATA”) I believe you can use the IN command, but I’m not positive if it works in Access. You can try it though. Syntax would be: SELECT * FROM YourTableName WHERE bday=’Sun’ … Read more

[Solved] Booking System Using C# winform [closed]

You’ll need to establish a connection to your database using a SQLConnection object or the appropriate class depending on your database. For instance: bool isReserved; using (SqlConnection connection = new SqlConnection(connectionString) using (SqlCommand command = new SqlCommand(“SELECT isReserved FROM YourTable WHERE BookingId = 1”, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) … Read more

[Solved] add data into primary key [duplicate]

The old way of doing this is a multi-step process: add the column which will be the primary key update the column enforce the primary key. Something like this: create sequence t23_id; alter table t23 add id number; update t23 set id = t23_id.nextval ; alter table t23 add constraint t23_pk primary key (id); In … Read more

[Solved] Custom hierarchy

Here is a generic method regardless of the level of the hierarchy. SQL — DDL and sample data population, start DECLARE @tbl table ( idGeo INT IDENTITY PRIMARY KEY, GEO VARCHAR(64), PARENTID INT ); insert into @tbl (GEO, PARENTID) values ( ‘EMEA’, NULL), ( ‘France’, 1), ( ‘mIDCAPSfRANCE’, 2), ( ‘Germany’, 1), ( ‘France exl … Read more

[Solved] Select Statement on Two different views

Yes, You can use two different view in SELECT query. You have to JOIN them, if them have matched column in each other. Just treat two different views as like two different tables when using in SELECT Clause. SELECT vw1.a, vw2.b FROM View1 vw1 INNER JOIN View2 vw2 ON vw1.id = vw2.id For Clarification, A … Read more

[Solved] Create condition that searches between two different WHEREs in the table

You can do the test for whether it’s home or away in the query itself. cursor.execute(“”” SELECT CASE WHEN robot_on_her_island = ? THEN ‘Last_War_on_her_island’ ELSE ‘Last_War_on_island_away’ END AS which_island, points_war_home, points_war_away FROM war WHERE ? IN (robot_on_her_island, robot_on_island_away) LIMIT 1″””, (select_robot_on_her_island, select_robot_on_her_island)) row = cursor.fetchone() if row: which_island, points_home, points_away = row if which_island == … Read more

[Solved] how would look a sql insert for this database tables? [closed]

If there were no foreign keys/triggers or something like that (please provide more info about that), the inserts would look like this: insert into language (languageID, language) values (1, ‘german’) insert into language (languageID, language) values (2, ‘english’) insert into word (id, language, text) values (1, 2, ‘lucky’) insert into word (id, language, text) values … Read more

[Solved] Using sum operation

I think you need this query: SELECT CompanyName, SUM(COALESCE(salary, 0) + COALESCE(bonus, 0) + COALESCE(others, 0)) AS TotalRemunaration FROM yourTable GROUP BY CompanyName I use COALESCE(fieldName, 0) that will return 0 when value of fieldName is Null. 0 solved Using sum operation

[Solved] Three joined tables query with many-to-many relationship in JPA [closed]

I think your SQL might look something like this: SELECT * FROM Hospital WHERE Postcode = 3000 AND Hospital_id IN (SELECT Hospital_id FROM Hospital_Medical hm INNER JOIN Medical_Service m ON hm.Medical_id = m.Medical_id where Medical_name=”Emergency”) AND Hospital_id IN (SELECT Hospital_id FROM Hospital_Language hl INNER JOIN Language_Service l ON hl.Language_id = l.Language_id where Language_name=”English”) solved Three … Read more

[Solved] return all rows of a table including duplicate rows

to get all rows, just use select * from tableName If you want to filter the duplicates out just add select distinct * from tableName if you want to group by, you can do: select column1, column2 sum(column1, column2) as sumCol from table group by column1,column2 or using a window function select * sum(column1, column2) … Read more