sql

Making a query more efficient for reads

Hi, I have a data model like the following: username | product1 | product2 ------------------------------- harold abc qrs harold abc def harold def abc kim abc def kim lmn qrs ... username | friend_username --------------------------- john harold john ...

Repeat function every id named "" with jquery

Ok i have this function what it does is takes the value of id time, user, title, and bodytext. Function to insert into sql. function getblogpost() { var date = $('#time').text(); var user = $('#user').text(); var title = $('#title').text(); var textbody = $('#bodytext').text(); var postid = $('#pid').text(); db...

MS Access - SQL Query question

System: Windows7, Access 2003, .mdb file, C# language, VS 2010 I'm doing queries with OleDbCommand, so I write the complete sql query in a string. Table Survey (Id) Table Questions (Id,IdSurvey) Table Answers (Id,IdQuestion) the tables are simplified to show only relevant data Assume 1 survey has 1..n questions Assume 1 ...

How to import *huge* chunks of data to PostgreSQL?

I have a data structure that looks like this: Model Place primary key "id" foreign key "parent" -> Place foreign key "neighbor" -> Place (symmetryc) foreign key "belongtos" -> Place (asymmetric) a bunch of scalar fields ... I have over 5 million rows in the model table, and I need to insert ~50 million rows into ...

FULLTEXT key too long

I get the following error when trying to add a FULLTEXT index to Title, Edition and Author in my MySQL database: Specified key was too long; max key length is 1000 bytes Here are the columns: `Title` varchar(255) NOT NULL, `Edition` varchar(20) default NULL, `Authors` varchar(255) default NULL, None of them are unique.. Even th...

FULLTEXT search on a very small column

I have a table Books in my MySQL database which has the columns Title (varchar(255)) and Edition varchar(20)). Example values for these are "Introduction to Microeconomics" and "4". I want to let users search for Books based on Title and Edition. So, for example they could enter "Microeconomics 4" and it would get the proper result. My ...

Is there MySQL example database like in Oracle?

Sometime ago, when I installed Oracle on Ubuntu, there was a sample database. Database contained Employees, Departments, ... Now I wonder is there something similar for MySQL? ...

Query optimization - VARCHAR equality vs Numeric equality

I have a large SQL Server database with about 40 columns and hundreds of millions of rows. This table is supposed to be loose in schema so I have a lot of columns as VARCHAR(MAX) even where it could have been BIGINT, DATETIME, INT etc. Does this have an impact on querying time/efficiency? e.g. will SELECT TOP 100 * FROM CustomerId = 3...

Why does query select (1/2) * 100 return 0 instead of 50 in SQL server 2005

I would like to get 50 as the output instead of 0. ...

Implementing (Date - Time Delta) in SQL Server 2008

I want to be able to send reminders for appointments. Given the tables: - Appointment ID (PK) Start - Reminder AppointmentID (FK) MinutesBeforeAppointmentToSendReminder -- only need minute resolution I would like to select reminder times: select ..., DateAdd(minutes, -Reminder.MinutesBeforeAppointmentToSendReminder, Appoint...

On What operations indexs do not work well or are not used

I am creating sql queries and I have read in one book that when using NOT operator or LIKE operators Indexes do not work. How much true this statement is. How can we avoid this if the statement is true. How a query should be made to do the same work avoiding these operators. What all other areas are there in sql server where Indexes are...

Merge duplicate records into 1 records with the same table and table fields.

I have a database table that contains a list of demographic records, some of those participant might have multiple/duplicate records, e.g. NOTE: Gender: 119 = Male 118 = Female Race: 255 = white 253 = Asian UrbanRural: 331 = Urban 332 = Rural participantid, gender, race, urbanrural, moduletypeid, hibernateid, and more fields 1, 11...

CHECK CONSTRAINT on multiple columns

Hi, I use SQL Server 2008 I use a CHECK CONSTRAINT on multiple columns in the same table to try to validate data input. I receive an error: Column CHECK constraint for column 'AAAA' references another column, table 'XXXX'. CHECK CONSTRAINT does not work in this way. Any other way to implement this on a single table without ...

Which ORM for codeigniter?

The quote below has convinced to finally go ORM. In the past I havn't really liked ORM and wrote it off as a stupid way of doing sql. Dealing with hierarchical data in sql is a pain I don't want to deal with. There's a reason we have these “Object-Relational Mapper” things, and it's because of a problem known as the Object-Relational...

(Oracle) how to group rows for pagination

I have a table that outputs similar to this (although in thousands): EMPNO ENAME TRANDATE AMT ---------- ---------- --------- ------- 100 Alison 21-MAR-96 45000 100 Alison 12-DEC-78 23000 100 Alison 24-OCT-82 11000 101 Linda 15-JAN-84 16000 101 Linda 30-JUL-...

CHECK for two columns

Hi, I have a problem with my code. As you can see i Try to have a sort of CHECK constraint using two columns in the same table but seems does not work. My need is to accept value in EffectiveEndDate only if they are > that EffectiveStartDate. Any idea how to solve it? thanks for your support! :-) CREATE TABLE dbo.Test ( EffectiveSt...

Hebrew encoding in sql server2005

i try this code in sql server 2005 declare @userName nvarchar(50) set @userName='איש2' print @userName but i get this ???2 what is the cause? it look like it replace the Hebrew char to "?" 10x ...

Give the solution of twice outer join

SELECT MaterialProcessSlip.*, Vendor.CompanyName , O.Name FROM MaterialProcessSlip ProcessSlip LEFT OUTER JOIN Vendors Vendor ON ( ProcessSlip.SubContractorId=Vendor.Id ) MaterialProcessSlip LEFT OUTER JOIN Operations O ON ( ...

Import negative numbers with SSIS 2005

I'm importing a flat txt file into SQL Server 2005 using SSIS. The problem is that negative numbers between -1 and 0 in the txt file are in a format without leading zero, e.g.: -.15 If I insert such number into my database using plain INSERT syntax it works without complaining. However, SSIS reports an error if it encounter such number...

synchronizing executeSql in Safari (WebKit) Web Sql database

WebKit (Safari 4+ is my focus) has a feature called Web SQL. Web SQL is specified in the W3C draft Currently only the asynchronous flavor is supported. I have a situation where I want to synchronize couple of operations - writing to database (using CREATE TABLE query and then a loop through INSERT queries) and then reading from the dat...