Should my database have a table or two?

I have a table test_cases which serves as a join table for builds and tests and also stores information about the duration of the test and the result(eg. 'success', 'failure', 'time_out') and the error_message in case the test_case failed: test_cases

The best n per group while returning content

I have looked at other answers but am having trouble applying the answers to my application. I have a query that returns something like the following: SELECT * FROM MYTABLE T; __________________________________________________________ | ID | AORB | .

SQL update to make a toggle

I want to make a toggle request as defined there T-SQL: Using a CASE in an UPDATE statement to update certain columns depending on a condition I did this : Update capteur join smartparking_reference on(smartparking_reference.id_capteur = capteur.id_c

Define groups of lines by logic

I have a unique scenario to which i can't find a solution, so i thought to ask the experts :) I have a query that returns a course syllabus, which each row represent a day of training. You can see in the picture below that there are rest days in the

why database links are bad for security

I heard database links are bad for organizations to use. Why is it bad for security?Where did you hear this? Database links, like any tool, have their uses and misuses. There is nothing inherently insecure about using a database link. But there are c

Join the sql windows table

I would like to insert a record into table RDV . The query of creation RDV Table: CREATE TABLE [dbo].[RDV] ( [idRdv] INT NOT NULL, [objet] NVARCHAR (50) NULL, [objectif] NVARCHAR (50) NULL, [DateRdv] DATETIME NULL, [commentaire] NVARCHAR (50) NULL, [

Problem with the SQL join

I have 3 tables: I have tried this so far: SELECT T1.P_id as id, T2.D_id, COALESCE(T2.count , 0) AS count FROM ( SELECT DISTINCT P_id FROM Comp_prod WHERE company_id = '15' ) AS T1 LEFT JOIN ( SELECT D_id, P_id, COUNT(P_id) AS count FROM userlogs WHE

where to put% sign correctly in a query of type sql?

ResultSet data = Db.db.search("select (flavour) from doenets where flavour like = '"+name+"%' "); i think there is something wrong with this like query i tried replacing the position of % sign but didn't work can someone tell me where

How can I convert a .sql file to an SAS file?

I have a .sql file which contains information about a database. This database has exactly 8 tables. I would like to essentially import the contents of these 8 tables into SAS and create .sas7bdat SAS datasets. Is there a quick/easy way to do this dir

If exists Update else Insert in. MySQL - PHP

I'm asking this question in order to find the best practice to do it. DB::table('owners') ->where('property_id',$id) ->update(array('person_id'=>$owner)); The problem is that in the table owners might not have a row to update. In that occasion i

How to select the result between two range numbers?

I need to select the result based on the column col1 value. col1,col2 is text field type. +-----+-----------+------+ | id | col1 | col2 | +-----+-----------+------+ | 1 | 1200-1220 | XXX | +-----+-----------+------+ | 2 | 1455-1460 | YYY | +-----+---

Query a nested game table to exclude all marked subtrees

I am creating a nested set with left and right columns. There is a column called exclusion. What I want to do is select all rows in the nested set but if the exclusion column is true, remove all other rows whose left and right column values fit betwe

Select the column of a table, where it is NULL in another

I'm trying to list data from a table, where the equivalent data in another table has not been entered. A bit wordy to explain but exactly what I'm trying to do is the following: I'm really stumped trying to pull data where it doesn't exist in room, a

doubt a lot to many relationships in Hibernate JPA

I have a couple of weeks starting with hibernate. I have this code database | TABLE A | ------------------------------- idA integer not null (PK) | name varchar(45) not null | lastname varchar(45) not null | | TABLE B | ------------------------------

SQL using the group by for more than just a table

I am trying to to get for all the departments, their location,number of employees, and the average salary. I have tried something like this but I've got a "not a group by expression" error: SELECT d.DEPARTMENT_NAME, l.CITY, count(e.FIRST_NAME),

Oracle SQL update using regexp_replace

I have almost 2000 rows in a table ("Sensor", which has many more than 2000 rows) in which I need to update one column, the sensorname. Part of the replacement within the update is based on the contents of another table, deviceport. Deviceport i

Transact SQL JOIN

I have the following query: SELECT MS.idReg, MS.dsMotivo, A.contrato FROM MS INNER JOIN S ON S.motivoSiniestro = MS.idReg INNER JOIN C ON C.n__contrat = S.n__contrat INNER JOIN A ON A.n__article = C.n__article Table MS has only 12 records, the ones I

DQL Doctrine larger-n-by-group

Here are 2 tables of my Symfony2 project : +-----------+ +----------------------------+ | EVENT | | PHOTO | +-----------+ +------+-----------+---------+ | id | | id | event_id | likes | +-----------+ +------+-----------+---------+ | 1 | | 1 | 1 | 90

Use the same name for a table as a schema

To put it simply, will bad things happen if I use a table name which is also a schema name. For example: Aircraft.AircraftNo reason why you can't do this, as far as I know, though you may confuse yourself later. I suppose things might get sticky if y

SQL - Get the number of users with middle age in the range

I know this should be painfully simple, but I'm having a mental block. I have three tables in a SQL Server 2008 database: Users: ID Birthdate (datetime) User_Visits: Site_ID User_ID Visit_Date Sites: ID I need a SQL statement that gets the count of s

Invalid identifier in Oracle function

This is my SQL; select a.hesap_no, a.teklif_no1 || '/' || a.teklif_no2 as teklif, a.mus_k_isim as musteri, b.marka, c.sasi_no, c.sasi_durum, d.tas_mar, nvl(risk_sasi(a.teklif_no1, a.teklif_no2, c.urun_sira_no, c.sira_no), 0) as risk, nvl(mv_sasi(a.te

How to deselect the field in a select query using sql

hi in my database i am store more than 50 field with primarykey (Auto increment) i am not sure about the fields name but i wants to select the entire data in that table , i am using SELECT * FROM tablename i want to select all the fields except that

Do you put your static database data into source control? How?

I'm using SQL-Server 2008 with Visual Studio Database Edition. With this setup, keeping your schema in sync is very easy. Basically, there's a 'compare schema' tool that allow me to sync the schema of two databases and/or a database schema with a sou

Accelerate sql JOIN

First of all, some background. We have an order processing system, where staff enter billing data about orders in an app that stores it in a sql server 2000 database. This database isn't the real billing system: it's just a holding location so that t