sql

What is the difference (when being applied to my code) between INT(10) and INT(12)?

If I use INT(12) vs INT(10) or INT(8) what will this actually do in terms of me using in code? (This is a spin off of a previous question) I read through the manuals and I think I understand what they're saying, but I don't actually know how it would apply to my php/mysql coding. Can someone provide an example of where this would actu...

CF Query appears to return incomplete data from text field

I'm using CF8 and SQL2000. I'm storing a bunch of HTML in a Text field in my SQL table. When I do a simple CFQUERY against that data, and CFDUMP it, it's truncated to 64000 characters. I've confirmed that my data is complete in the SQL table, by selecting the tail end of the data using SELECT Substring, and confirmed the length using...

SQL Server 2005 - Check for Null DateTime Value

Hello, I'm trying to count the number of records that have a null DateTime value. However, for some reason, my attempts have failed. I have tried the following two queries without any luck: SELECT COUNT(BirthDate) FROM Person p WHERE p.BirthDate IS NULL and SELECT COUNT(BirthDate) FROM Person p WHERE p.BirthDate = NULL What...

Database schema design: What to do about unverified invitations?

I'm not quite sure how to approach this issue: I am creating a web application that has an invite only registration system. An admin user sends an email invitation to a user, the user clicks the link, and takes them to a page where they can create an account that has been linked to their email address. My initial idea was to insert a r...

Duplicate a record in MySQL

I have a table and I want to duplicate specific rows in the table. I know this is not the best way to do things but we are looking for a quick solution. Here's something harder than I initially thought, all I need to do is copy an entire record to a new record in an auto-increment table in MySql without the need to specify each field. T...

UPDATE before INSERT (Oracle)

hello, I have two schemas S1 and S2 with identical table structure. I`ll start with example: on S1.table1 I have: ID DATA1 DATA2 01 data1 test1 02 data1 test1 on S2.table1 I have: ID DATA1 DATA2 01 data2 test2 02 data2 test2 Is it possible to select one row (from S1.table...

How do I compare two columns for equality in SQL Server?

I have two columns that are joined together on certain criteria, but I would also like to check two see if two other columns are identical and then return a bit field if they are. Is there a simpler solution than using CASE WHEN? Ideally I could just use: SELECT Column1 = Column2 AS MyDesiredResult FROM Table1 INNER JOIN Tab...

Various Moving Annual Totals in an SSAS Cube

This is how I am creating my moving totals as columns in my cube: MATTY (Moving Annual Total This Year) SUM ( { [Time Period].[Month].CURRENTMEMBER.Lag(12) : [Time Period].[Month].CURRENTMEMBER }, [Measures].[MeasureColumnName]) MATLY (Moving Annual Total Last Year) SUM ( { [Time Period].[Month].CURRENTMEMBER.Lag(24) : [Time Period]...

Building conditional statement across multiple models (CakePHP 1.2.5)

Let's say I have 3 models: User, Region, Country. User belongsTo Region Region belongsTo Country Each of these models is using the Containable behavior. I'm attempting to find users from the country with code 'US'. Here's what I'm attempting: $users = $this->User->find('all', array( 'conditions' => array('Country.code' => 'US')...

ms-access simplying SQL code

is this good code? can it be simplified somehow? SELECT u.id,u.title,u.title,u.first,u.last FROM (((tblusers u LEFT JOIN tbluserstudentteacher ON u.id = tbluserstudentteacher.student_teacher_user_id) LEFT JOIN tblUsersSubjects ON u.id = tblUsersSubjects.user_id) LEFT JOIN tblUserAvailability ON u.id=tblUserAvail...

Sorting results when autocomplete matches multiple columns in SQL

I've run into an issue with an autocomplete field I'm working on. The field I'm working with is composed of the form "<NAME> (<CODE>)". When a user starts typing in text, I want to display any results that match either NAME or CODE. For example, if this list contains items and their codes, like "Personal Computer (PC)", then I'd want ...

Sql Query First, Next, Last Rows in a Set

I have two tables that I am trying to join together multiple times. The Parent table is called Jobs, and the child table is called Routings. A Job can have 1 or more Routings. I need my output to contain one record for each job, joined with three separate joins to the Routings table. One join is for Current data (the first null date ...

How to put parameterized sql query into variable and then execute in Python?

I understand that the correct way to format a sql query in Python is like this: cursor.execute("INSERT INTO table VALUES (%s, %s, %s)", var1, var2, var3) so that it prevents sql injection. My question is if there is a way to put the query in a variable and then execute it? I have tried the example below but receive an error. Is it pos...

SQL Server 2005 - Nested recursive query :(

I have a query that I need to execute that I do not know how to structure. I have a table called Employees. I have another table called Company. There is a third table called Files. As you can imagine, a Company has Employees, and Employees have Files. I need to list out all of the Employees in my database. The challenge is, I need to ...

Oracle - natural sort rows on multiple levels

Using Oracle 10.2.0. I have a table that consists of a line number, an indent level, and text. I need to write a routine to 'natural' sort the text within an indent level [that is a child of a lower indent level]. I have limited experience with analytic routines and connect by/prior, but from what I've read here and elsewhere, it seems ...

Customizing FreeTextTable in MS SQL 2000

I'm looking for answers for the following 2 questions (SQL Server 2000). I have an order info table that is indexed so that I may search data on particular columns. So, an example query I might run is: SELECT top 50 ft_tbl.*, key_tbl.Rank from OrderInfo as ft_tbl INNER JOIN FREETEXTTABLE(OrderInfo, Address1, 'W Main St') as key_tbl ...

How to know where AS keyword should be used ?

Hi everyone, There is a AS keyword in TSQL but in what situations I should use it ? For example : Create View StatisticalData AS Select * from People We used AS keyword in this statement but when creating tables we don't use it , I mean I am kinda confused. Could you please tell me, in what kinda position I should use AS. I mean it i...

Indexing performance null vs dummy data

I have a table with a InTime and an OutTime column. Normally when I insert data into this table I set the InTime to a DateTime and the OutTime to null. When the data is removed a OutTime value is set. When I’m getting data out for a particular time I use something like: where InTime < sometime and OutTime is > sometime or OutTime is n...

user defined functions

I have this user defined function. public partial class UserDefinedFunctions { static int i; [SqlFunction(IsDeterministic = true)] public static SqlSingle f() { return new SqlSingle(1.3F); } }; But it only works if i is readonly. Why? ...

How can I exclude values from a third query (Access)

I have a query that shows me a listing of ALL opportunities in one query I have a query that shows me a listing of EXCLUSION opportunities, ones we want to eliminate from the results I need to produce a query that will take everything from the first query minus the second query... SELECT DISTINCT qryMissedOpportunity_ALL_Clients.* FRO...