I'm currently running the following query:
SELECT * from people WHERE id = 4;
on the following table:
id name state age
-----------------------------------
1 tony jones CA 22
2 Sue Smith FL 50
3 Alex Guam AL 44
4 tony jones SC 32
5 tony jones OH ...
I just found a bug in my Rails app which would lead to certain records not getting deleted with their associated objects. The bug has been fixed, but I now have several thousand records in my database with foreign key values pointing to records that don't exist.
Is it possible to delete all records in a table where an integer foreign ke...
I want to preface this by saying I believe the Right Way to handle this is probably to restructure the database tables BUT
I have a job for a client where he is purchasing a database of most of the golf courses in the US. Since he will receive updates periodically from seller I have preserved structure as sent. (Nasty aside: jackass s...
I've inherited a web application which strictly uses stored procedures to do its job. I like the approach of making it impossible for frontend developers to break the database, but I've been tired of writing calls to SPs with plain SQLs and wanted to have something saner. While I've been looking for a decent ORM (for Perl in this case, b...
i have field X that contain text with spaces in the end of the text
how i can remove them ?
i need it in any sql query for oracle 10g
...
Hello,
I have a MySQL database (named "sitefeather") which will eventually have several tables with identical structures. The structure is this:
id INT(11) NOT NULL auto_increment, site VARCHAR(1000) NOT NULL, action1 BIGINT(9) NOT NULL, action2 BIGINT(9) NOT NULL, createddatetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(id), ...
I'm a newbie.How many number of tables are recommended in a SQL Server Express database? mainly attaining best performance speedwise as an objective. Is it generally recommend to use two databases as compared to one for a single application? Your quick response will be highly appreciated
...
In Oracle, is it possible to INSERT or UPDATE a record (a row) through a view?
...
Let's say my DB Scheme is as follows:
T_PRODUCT
id_product (int, primary)
two entries: (id_product =1) , (id_product =2)
T_USER
id_user (int, primary)
id_product (int, foreign key)
name_user (varchar)
two entries: (id_product=1,name_user='John') , (id_product=1,name_user='Mike')
If I run a first query to get all products with their...
Hi, I'm having problems running this query. I keep on getting the error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read = 'readd' WHERE user_id = '1' LIMIT 1' at line 1
The code
$conn = mysql_connect('localhost', 'admin', 'root') or die(m...
I'm trying to write a webapp with CakePHP, and like most webapps I would like to create an installer that detects whether the database has been initialized and, if not, executes the installation process.
This process will be entirely automated (it assumes the database itself already exists, and that it is granted full administrative acc...
Suppose we have the contents of tables x and y in two dataframes in R. Which is the suggested way to perform an operation like the following in sql:
Select x.X1, x.X2, y.X3
into z
from x inner join y on x.X1 = y.X1
I tried the following in R. Is there a better way?
Thank you
x<-data.frame(cbind('X1'=c(5,9,7,6,4,8,3,1,10,2),'X2'=c(5,...
The database I'm designing has 3 major tables: BOOKS, ARTICLES, NOTES.
Each book or article can have multiple notes, my original design was just like that, which means both notes on books and notes on articles go the 'notes' table. Here are the columns for the NOTES table:
note_id
note_type
note_type_id
note_content
NOTE_TYPE can be ...
I'm parsing a json feed routinely and need to insert only the newest users from the feed and ignore existing users.
I think what I need is ON DUPLICATE KEY UPDATE or INSERT IGNORE based on some searching but I'm not quite sure which is why I'm asking - so for example:
users
1 John
2 Bob
Partial JSON:
{ userid:1, name:'John' ...
Ok, let's say from start I'm not a SQL ninja. Anyway I'm using SQLite in a tiny project of mine. I've this test table:
CREATE TABLE [prova]
(
[id] INTEGER PRIMARY KEY UNIQUE,
[str] TEXT NOT NULL
)
and this query won't work:
insert into prova (id, str)
select null as id, "foo" as str
where not exists (select * from pr...
I have two tables Events and FixedPlace
CREATE TABLE `events` (
`idEvents` int(10) unsigned NOT NULL AUTO_INCREMENT,
`NumberOfPlaces` int(10) unsigned DEFAULT '0',
`FpOddsPrice` double DEFAULT '0',
PRIMARY KEY (`idEvents`),
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;
/////////////////////////////////////////////...
I'm trying to implement a custom form builder, similar to those provided by Wufoo and Google.
While I've created a simple UI to create these custom forms with, my issues lie in the database design. Upon creating the form, a JSON implementation is saved in the database (would like to improve this) and referenced to build the form that a ...
I am having trouble with the following MYSQL query and are hoping that there is someone that can help me with it.
Here is the query:
SELECT *
FROM dbcasino_db22.tb_content
WHERE content_real_folder = 'foldername/' AND content_no < 5099
This query works but gives me all the records smaller than 5099 that match the content_real_folde...
A production table of mine contains over a million records. An requirement calls for a paging query to retrieve records by OFFSET and LIMIT parameters(similar to MySql's LIMIT clause), without sorting the result set, just as rows' natural order are in a table-scan, since 'ORDER BY' generates unacceptable performance impact, including 'OR...
Could you please help me with present SQL?
I am copy 1 table to another table and the same time merge the fields.
I get an error on the +
INSERT INTO [dSCHEMA].[TABLE_COPY_TO]
(
[FIELD_A],
[FIELD_B],
[FIELD_A] + '-' + [FIELD_B]
)
SELECT [FIELD_A]
,[FIELD_B]
FROM [dSCHEMA].[TABLE_COPY_FROM]
...