sql

listing visits in last 24 hours.

I am trying to list last visits per hour in last 24 hours. I thought the following code would do it, but I get the outcome below. Any idea where I screwed it up? [,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0],[,0], Dim ListHours() HoursInCurrentDay = "24" Redim ListHo...

GETDATE last month

I am trying to list last a website's statistics. I listed Last 30 days with; CONVERT(VARCHAR(10), S.DATEENTERED, 101) BETWEEN CONVERT(VARCHAR(10), GETDATE()-30, 101) AND CONVERT(VARCHAR(10), GETDATE(), 101) and this month with; RIGHT(CONVERT(VARCHAR(10), S.DATEENTERED, 103), 7) = RIGHT(CONVERT(VARCHAR(10), GETDATE(), 103), 7) but ...

How can I get around this foreign key constraint having to have a unique name?

I'm not sure why these have to be unique, but from reading the MySQL forums it appears that they do. However, I think it has something more to do with the INDEX name. I have two tables that have foreign key constraints referencing the same primary key on a third table. If it helps, I'm using MySQL workbench to design the schema. I usua...

Speed up this code - PHP/SQL - Short Code but takes incredibly long at the moment

Right, this code goes through a rather large multidimensional array (has about 28,000 rows and 16 parts). Order of events: Check if the data exists in the database if it exists - Update it with the new data if it doesn't exist - Insert it Simple. But right now to go through this it has taken over 30min i think and Still going. $c...

SQL query with multiple "IN" on same many-to-many table

Hello, I've got m2m relationship like this: #main table CREATE TABLE products_product ( id integer NOT NULL, company_id integer, user_id integer, type_id integer NOT NULL, name character varying(100) NOT NULL, description character varying(200) NOT NULL, tags character varying(255) NOT NULL, image charac...

How will SQL Server perform this query behind the scenes

SELECT * FROM myTable WHERE field1 LIKE 'match0' AND myfunc(t1.hardwareConfig) LIKE 'match1' Here is my question, the matching of field1 is fast and quick, but myfunc takes forever to return and I want to make sure that if field1 doesn't match that it doesn't even attempt to do myfunc. Will SQL just know this or can I make it...

MS Access VBA/SQL question! Pretty Simple

Hey I just sort of learned how to put my SQL statements into VBA (or atleast write them out), but I have no idea how to get the data returned? I have a couple forms (chart forms) based on queries that i run pretty regular parameters against, just altering timeframe (like top 10 sales for the month kinda of thing). Then I have procedures...

Outputs all minus one

I use this code to output all threads with a specific forum ID $query = mysql_query("SELECT * FROM forums JOIN threads ON threads.fid = forums.id WHERE forums.id = ".intval($_GET['forumID'])); $forum = mysql_fetch_assoc($query); ?> <h1><a>Forums</a> &gt; <?=$forum['name']?></h1> <?php while ($thread = mysql_fetch_array($query)): ...

Help with Pagination

How would I do to bold the page I'm on and make it unclickable? In the link at the bottom? If I'm on page 3 for example: 1 2 3 4 This script: // how many rows to show per page $max = 15; $page = $_GET['page']; // if $page is empty, set page number to 1 if (empty($page)) $page = 1; $limit = ($page - 1) * $max; $sql = mysql_query("...

SQL Server snapshot isolation level issue

Hello everyone, I am studying snapshot isolation level of SQL Server 2008 from the below link. My confusion is, http://msdn.microsoft.com/en-us/library/ms173763.aspx It is mentioned "Data modifications made by other transactions after the start of the current transaction are not visible to statements executing in the current transact...

recommend a tutorial for database type project in VSTS2008?

Hello everyone, I am interested in and new to database type project in VSTS2008. I am especially interested in how this new type of project could benefit my development work (previous I always develop all SQL stuff inside SQL Server Management Studio), and whether this type of project could facilitate deployment of database. Appreciate...

Oracle SQL: Create Type Object with Reference to another?

Hey, I need some help ;) I got an Object object1 of the Type (id, ob1 REF object2, ob2 REF object2). These objects2 Types already exists, and I have to create a new object1 with references to the two differen object2 things. What I am trying right now: DECLARE t_ref REF object2; t_ref2 REF object2; BEGIN SELECT REF(*) INTO t_r...

SQL Injection in Java/MySQL - multiple queries

Hi everyone, I've got a web application with an SQL injection as part of an INSERT statement, it looks like this: INSERT INTO table1 VALUES ('str1', 1, 'INJECTION HERE') I can insert the regular multiple-query injections such as ');truncate table1;-- but due to the fact that Java+MySQL is used it does not allow stacking multiple queri...

Has anyone written a higher level query langage (than sql) that generates sql for common tasks, on limited schemas.

Sql is the standard in query languages, however it is sometime a bit verbose. I am currently writing limited query language that will make my common queries quicker to write and with a bit less mental overhead. If you write a query over a good database schema, essentially you will be always joining over the primary key, foreign key fie...

How to parse a SQL query result and modify it, using C# ?

I'm trying to do something very simple, yet I can't seem to find the proper way to do it. I have a MySqlDataAdapter object which contains the result of a query. I want to parse the results of this query before rendering them in an ASP.NET Repeater. (convert date from Unix Epoch to human readable, that sort of things). So far, I'm unabl...

Does performance of a database (SQL Server 2005) decrease if I shrink it?

Does performance of a database (SQL Server 2005) decrease if I shrink it? What exactly happen to the mdf and ldf files when shrink is applied (Internals???) ...

Simple SQL question

(I couldn't make up a good title, sorry) So I use this pagination: $page = $_GET['page']; $max = 5; // if $page is empty, set page number to 1 if (empty($page)) $page = 1; $limit = ($page - 1) * $max; $sql = mysql_query("SELECT * FROM posts ORDER BY date DESC LIMIT $limit, $max"); $totalres = mysql_result(mysql_query("SELECT COUN...

Accounting System design & databases

I am working on a simple invoicing and accounting applications, but I am totally lost on how to represent accounting-transactions(journal-entries) in a database. Using a separate debit and credit column in the database seems like one way, but most of the Open Source Accounting I have seen use a single amount column. This I assume simplif...

What will happen if records are deleted during the data retrieving process?

Let's say I have 6 records, and I set the fetch size as 2. [Id] [Name] 11 A <-- 1st fetch, start from 1 position 21 B 31 C <-- 2nd fetch, start from 3 position 41 D 51 E <-- 3rd fetch, start from 5 position 61 F If 1st user issues a "SELECT * from tablex", and 2nd user issue a "DELETE FROM tablex WHERE Id = 2. ...

tracking IP addresses

I want to track IP addresses visited my website. I want to know what time and what page they visit. I store ip address in VISITORIP, date entered in DATEENTERED and page URL in HTTPADDRESS columns. I want to group them by dates. My outcome should be like: TIME PAGE 7/12/2009 3:16:27 PM ?Section=products&SubSection=...