How to know if all the cells have the same value in some column (title changed)
I want to have a bit scalar value that tells me if all the values in a column equal something:
DECLARE @bit bit
SELECT @bit = TRUEFORALL(Name IS NOT NULL) FROM Contact
UPDATE
I now realized that I actually don't need the TrueForAll, what I do need is to ...
I'm working on a MySQL database that contains persons. My problem is that, (I will simplify to make my point):
I have three tables:
Persons(id int, birthdate date)
PersonsLastNames(id int, lastname varchar(30))
PersonsFirstNames(id int, firstname varchar(30))
The id is the common key. There are separate tables for last names and firs...
In PHP, I create and execute SQL queries like the following.
INSERT INTO Table (Column1, Column2, Column3) VALUES
('1', '2', '3'),
('A', 'B', 'C'),
('AA', 'BB', 'CC');
However, the order in which they are inserted into the database is different every time I try this. Is there a way that I can ensure that they are inserted in the order...
If I want to select all records in a table that have not been processed yet and then update those records to reflect that they have been processed, I would do the following:
SELECT * FROM [dbo].[MyTable] WHERE [flag] IS NULL;
UPDATE [dbo].[MyTable] SET [flag] = 1 WHERE [flag] IS NULL;
How do I ensure that the UPDATE works on only th...
select * from table1 join table2 on table1.column3=table2.column4 where ...
...
$row=mysql_fetch_assoc($result);
However, there are two columns in the new table(table1 join table2) which have the same column name, how to get the values of both respectively?
...
For example, I have a shop order database, and two tables in it - ORDERS and ORDERSTATUS.
Table : orders
--------------------------------------------
OrderID | OrderItems | AddedTimeStamp |
--------------------------------------------
1 | Apples | 2009-12-22 13:15:18 |
--------------------------------------------
2 ...
Does a MySQL MyISAM table gets locked when records are deleted from it?
...
Hi,
I have 2 big tables in sql server that i need to sync to mysql.
now, i need that as an ongoing process.
the tables are 1 GB each and getting new/update/delete row every 0.1 second.
Can you recommend me a tool that can do it that is not resource expensive.
you can offer OPEN SOURCE and commercial as well
Thanks
...
Greetings, by using the psycopg2 library of python, I can currently connect to a DB and retrieve such like this:
conn = psycopg2.connect("dbname='db1' user='postgres' host='xxxxxx' password='mypass'");
qr = conn.cursor()
qr.execute("SELECT avg(pavg) FROM mytable WHERE id =5")
Now beside the database named "db1", I have to query anothe...
I need to find out the user who has posted the most number of comments. There are two tables 1)users(Id, DisplayName) 2)comments(Id, UserId, test) . I have used the following query
Select DisplayName from users INNER JOIN (Select UserId, max(comment_count) as `max_comments from (Select UserId, count(Id) as comment_count from comments gr...
Model Icolor
m1 i1
m1 i2
m1 i3
m2 i2
m2 i3
m2 i4
I am having a table like this, i need to select Icolor values which is common to both model m1 and m2.
...
I have a column that stores data like (42,12). Now I want to fetch 42 or 12 (two different select queries). I have searched and found some similar but much more complex scenarios. Is there any easy way of doing it? I am using MSSQL Server 2005.
Given there will always be only two values and they will be integer
...
Hi,
I have a CSV file which contains an ID and several other columns. I also have a table in oracle where the ID identifies a row. How can I best replace the values that are in the table with the values in the CSV file while keeping the other columns the way they were before?
This has to be done with tools available in oracle itself (...
I am using perl DBIx::Class ORM and would like to be able to dynamically generate an XSD either from the DBIX::Class schema or directly from the SQL DDL.
I know it would probably be better that we start with XSD and generate our SQL DDL from the XSD but we are not in a position to do that yet.
thanks, Tom
...
users
id
username
friends
user_id (invitor)
friend_id (that get invitation)
accepted
Now If user #1 invites user #2 to be a friend and #2 acceptes, I want user 2 displayed on user 1's site and user 1 on user 2's site
But i cant figure out how the query for this should look. Been scratching my head for a long while
help would be...
Can someone please give me a simple explanation of an inner equijoin?
I'm finding explanations found via google quite hard to understand.
...
CREATE TABLE exmp_test
(
id int,
v1 int,
v2 int,
v3 int,
v4 int
)
SELECT * FROM exmp_test
id v1 v2 v3 v4
1 2 4 6 7
1 4 77 3 8
I want to add the value of the [id] column to (whichever has least value for v1 ,v2 ,v3 ,v4) for each row.
As an example, for the first row, the [id] value should be add to v1 (because it ...
Every change of data in some row in database should save the previous row data in some kind of history so user can rollback to previous row data state. Is there any good practice for that approach? Tried with DataContract and serializing and deserializing data objects but it becomes little messy with complex objects.
So to be more clear...
We have a large Oracle database with many tables. Is there a way I can query or search to find if there are any tables with certain column names?
IE show me all tables that have the columns: id, fname, lname, address
Detail I forgot to add: I need to be able to search through different schemas. The one I must use to connect doesn't o...
I have a titles table of about 14000 records, with a float field average_rating, which is indexed. But when I try to get the first 48 records with the highest average_rating, the index doesn't do any work. What am I doing wrong?
mysql> explain SELECT * FROM `titles` WHERE (average_rating is not null) \
ORDER BY average_rating desc LIMIT...