sql

Ultra simple ASP SQL on GoDaddy free hosting.

I know it can be simple to access a mysql or sql database on godaddy.. i have done it before, but now i have lost the code. Now the code that should be working just comes up with a security exception. So how do i create a asp or aspx file on my godaddy free hosting account that will connect to a database i have already set up (mysql,sql...

PHP MySQL getting top five highest results. ?

have a poll table which has 10 categories and I want to view the top 5 results from highest to lowest limit into 5 categories. How can I do this in php and mysql? here are example tables categories id category_name Votes id category_id user_id Users id username here is my sample query: $q = mysql_query("SELECT * from categ...

How to group mysql rows with same column value into one row?

I have to tables, keywords and data. Table keywords have 2 columns (id, keyword), table data have 3 columns (id[foreign key of keywords.id], name, value). I am using this query: SELECT k.id, d.value, d.name FROM keywords AS k INNER JOIN data as d ON k.id = d.id it returns something like: 1 123 name1 1 456 name2 2 943 name1 3 542 n...

len of varbinary 2

hello, this is a followup question to http://stackoverflow.com/questions/3661641/len-of-varbinary len(0x0a0b0c0d) returns 4 because len counts bytes. does this behaviour depend on the current server collation? if i chose utf-16 for example, would it return 2? in other words, does len treat its argument as string or does it distinguish ...

It is possible to fetch with a single SQL the minimum (maximum) row in the table when the compared value is combined of two separate fields?

Dear ladies and sirs. Examine the following scenario. There is a table with two columns - DateWithoutMilliseconds and Milliseconds. Together these two columns define the exact timestamp with the milliseconds. Is it possible to write a single SQL statement (not using stored procedures) which would fetch the row with the minimum timestam...

Using domain database in subdomain

Is it possible that we have one domain where database and site is hosted on the single dedicated IP. If we wish to host domains subdomain on another dedicated IP address and use the domains databse to display quotes. Will it be done or not. Or we have to host the subdomain also in same domain with same IP address? ...

Date Range in PL/SQL

If I have table with a Date column (Date field) called created_date, with values like "9/2/2010 5:25:42 PM". I want to select all rows from a start_date to a end_date. However, the end_date may be null. In this case, I want to select all rows where created_date is greater than end_date. ...

ASP.net Beginner question: How to get rid of this error ?

Trying to create a simple login page in Asp.net C# but getting some error... I googled about the error... Tried all the solutions but to no avail... What am I doing wrong? The error is: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible...

Inserting an 'image' datatype value through SQL Query/C++

In the application I develop, the database table having a column of 'image' datatype. Now I want to insert the values into that table directly from my program, which is in VC++ 6.0, using a direct ExecuteQuery() of INSERT(due to performance considerations). The image column is been mapped to the structurre of the following declaration t...

Function won't accept less than three arguments

Hello Stack Overflow! I'm working with someone else's database connection PHP function that works fine as long as I pass it at least three arguments. If I pass it two argument, then the apache log says: mysql_real_escape_string() expects parameter 2 to be resource, null given I need the function to take a SQL query like so: $sql = D...

Count of total groups required. Group by cluased query in MySql

Hi; I want the count of a total groups. I have following query. I want how many groups this query returned based on web_id. Lets suppose if it grouped under 4 groups. I need count 4. select * from web_details where redirected = false group by web_id I hope my question is understood. ...

How to get unique result in mysql.

I have table: name marks aaa 100 aaa 56 aaa 120 bbb 56 bbb 60 The result should be: aaa 120 bbb 60 ie unique name with maximum marks. Is there any query in mysql? ...

How can I make this query in SQL Server 2005 Compact Edition 3.1?

Hi, this subquery works in SQL Server 2005 Compact Edition 4 SELECT TableA.serialNo FROM TableA, (SELECT MAX(TableB.lotNo) AS lotNo,TableA.codeA,TableA.codeB FROM TableA, TableB WHERE (TableA.codeA =TableB.codeA) AND (TableA.codeB = TableB.codeB) AND ((LEN(TableA.openDat...

Perfecting SQL binary to IP Address string conversion

We use a binary(16) field to store IP Addresses. We do this as it can hold both IPv4 and IPv6 addresses and is easily used with the .Net IPAddress class. However I have created the following SQL function to convert the binary address to the IP Address string for reporting purposes. CREATE FUNCTION fn_ConvertBinaryIPAddressToString ( ...

Insert with select subquery using SqlCommand

I am having a problem when using an INSERT statement with a nested select. The query works when executing it in the SQLManagement Studio but returns an error when executing it in code. The query looks like : INSERT INTO [Projects] VALUES ('1', 'None', '2', '2010/09/08 10:36:30 AM', 4, 1, 4, '6', '', 'n/a', 'no', 'n/a', 'None', 0,...

How to COUNT column values differently in a VIEW?

I have a column in Datablase Table, Suppose its Observation which contains three types of values Positive Negative NULL Now I want to count the Total no of rows , Total Positive and Total Negative and some other columns. I can not use Where clause here. And its a view So result should be like Total Positive Negative SomeOthe...

Sub-query in tuple constraint DB2

Hi, In my database course we use a book (Database System - the Complete Book) which says the following is a valid create table statement in standard SQL: CREATE TABLE Participants ( meetid INT NOT NULL, -- ... CONSTRAINT RoomConstraint CHECK (1 >= ALL (SELECT num FROM Numbers) ); But DB2 complains and gives 20 pos...

Can't return row id 17 by getGeneratedKeys()

I'm using sqlite JDBC 0.56 and the table is created using fts3 MY table is created by stat.executeUpdate("CREATE virtual TABLE doc using fts3 (doc_name , doc_path);"); seems the problem is caused by this virtual table. I tried to insert a set of record into a database and return the generated key. But I find that when the key is bec...

Having problems converting conditional where clause in LINQ back over to SQL

Hello all. I've got myself in a bit of a pickle! I've done a snazzy LINQ statement that does the job in my web app, but now I'd like to use this in a stored procedure: var r = (from p in getautocompleteweightsproducts.tblWeights where p.MemberId == memberid && p.LocationId == location...

SQL Server: How do I update dates so that they are two months prior?

Could anyone advice me on how I could run an UPDATE statement in SQL Server to take a number of given DATETIME fields and deduct two months from them? ...