I have a SQL table with three columns X, Y, Z. I need to split it in groups in such a way that all records with same value of X or Y or Z are assigned to the same group. I need to make sure that the records with same value X or Y or Z are never split across multiple groups.
If you think of records as nodes and values of X, Y, Z as edges...
In case I need to change the PK of a single row from 1 to 10, for example, is there any way to trace every proc, view and function that might reference the old value?
I mean, a simple select in a proc like: select * from table where FK = 1 would break, and I'd had to look for every reference for ones in every proc and view and change th...
I have a T-SQL stored proc that supplies a good amount of data to a grid on a .NET page....so much so that I put choices at the top of the page for "0-9" and each letter in the alphabet so that when the user clicks the letter I want to filter my results based on results that begin with that first letter. Let's say we're using product na...
I have a poorly normalized set of tables and am trying to correct this issue. The DB is MS SQL 2005.
Table1 has an id field (record ID), a mainID field (person ID) and a sequence field (and int that determines the sort order)
Table2 has its own id field and a copy of the id for the first record by a person (sequence = 1).
I've added ...
Trying this answer and not having any luck:
I am using the SQLite Database browser (built with 3.3.5 of the SQLite engine) to execute this query:
SELECT columnX FROM MyTable
WHERE columnX LIKE '%\%16' ESCAPE '\'
In column XI have a row with the data: sampledata%167
I execute the statement and get no data returned but no err...
I have a variable $word and I'd like to match it in my select statement
somethig like this: "select * from table where column regex '[0-9]$word'"
but this doesnt work, so how can i put a variable in a regular exprssion?
Thank you
...
Hi,
I have a table linking customers to previous purchases:
RecID CustID ProdID
1 20 105
2 20 300
3 31 105
4 45 105
5 45 300
6 45 312
I'd like to get a list of CustIDs that bought Item 105,
but did NOT but Item 300.
In this case, CustID 31.
I can't se...
So I am a beginner to this, and trying to follow my professors instructions on how to complete this. They are as follows:
Consider the relational database described in Tables 1-3. The underlined attribute(s) is the primary key for a table. Use your Oracle account to create this database and to insert the tuples listed in each table. ...
How to Create a Table in Oracle with name [email protected]
I tried doing CREATE TABLE [email protected](..)
but this gives me error so i was looking for some other way of doing it
...
Which procedure is more performant for an update which affects zero rows?
UPDATE table SET column = value WHERE id = number;
IF SQL%Rowcount > 0 THEN
COMMIT;
END IF;
or
UPDATE table SET column = value WHERE id = number;
COMMIT;
In other words if an Update affect ZERO rows and a commit is issued am I incurring any added expense ...
How can I match a word in a sentence from a column using regex? I tried:
"select * from table where column regex '/\b".$text."\b/i'"
but that didn't work. Thanks in advance.
...
What is the most common naming convention for SQL Database tables?
Was it historically one way and now it's better to do another way?
What are the most common practices now?
...
I am using MySQL 5.1.47 on a Mac.
I have created a table named Stay in a database named LEAD.
When I do a show tables command, Stay appears in the list.
When I try to insert something into that table, MySQL tells me that it cannot find the 'stay' file, and gives me an errno of 2.
MySQL documentation indicates that if you get an errno...
I'm using DbLinq with SQLite for a small project of mine. Is there any way to look at the actual SQL queries that get executed behind the scenes?
I remember a monitoring program for SQL Server from my internship but SQLite is a quite different beast, I fear.
...
All language like C#,VB.NET all have try catch finally block but SQL server only have try and catch only why not finally block is given is there any specific reason for that?
...
I want to create a stored procedure like this:
PROCEDURE P_CUSTOMER_UPDATE
(
pADSLTable IN Table,
pAccountname IN NVARCHAR2,
pStatus IN NUMBER,
pNote IN NVARCHAR2,
pEmail IN NVARCHAR2,
pMobi IN NVARCHAR2,
pServiceTypeID IN NUMBER,
pDate IN DATE
)
IS
BEGIN
UPDATE pADSLTable
...
Hi guys i have a model livestream which has two columns in the database, 'user_id' and 'activity_id'. Very straight forward.
Now when I try to insert multiple records into the database I get an invalid SQL statement:
SQLite3::SQLException: near ",": syntax error: INSERT INTO livestreams (user_id, activity_id)
VALUES (1, 2), ...
I am building up a database of movies. Each movie will have fields genre, actors, director etc. Now my question is how do I design a database and write SQL as each movies can have multiple actors or directors etc.
Right now my database design for table movie is:
movie_id
movie_title
actors_id
directors_id
genre_id
But this way it se...
i have been asked to write a query which in should rank customers base on the quantity of orders they have. the main important factor is that if two customers have been ordered the same quantity they should have be in same rank. i want to know the way to handle this query. for this i have began as below:
select tble1.customerid, RANK()...
i want to define a scaller fucntion which in that im giong to return the result into a variable but i do not know how to do this.
CREATE FUNCTION dbo.Funname ( @param int )
RETURNS INT
AS
declare @returnvar int
select @returnvar = select colname from tablename where someconditions = something
return(@returnvar)
i want to make a funct...