sql

How to identify a database as valid model?

Im having trouble identifying my databases as correct and valid version of my model. I have a GUID-id for my model I could use, but where do I put it? I dont want an entire table with only one row for this GUID. Is there any metadata-repository for databases (SQL Server 2008) or is there any other methods of identifying databases except ...

How to find the highest populated instance in a column in SQL.

Hey, So I have a table (person), that contains columns such as persons name, age, eye-color, favorite movie. How do I find the most popular eye color(s), returning just the eye color (not the count) using SQL (Microsft Access), without using top as there might be multiple colours with the same count. Thank you ...

MySQL find crossovers in a table for different profiles for a same user

I have two tables one is table Profile and other is table Profile_location (stores the relation of a profile and a location). Problem: A user can have multiple profiles, each profile has different locations. I want to find crossover of locations between each profile of a given user. In other words, evaluate all the profiles of a given u...

SQL query to get the structure of a table of datbaseA in serverA

I need to get the strucure(field names and its datatypes) of a table ,that is in databaseA of serverA ...

One query to retrieve from two tables?

Let's say I have two tables: one stores links and contains a link_id column, and the other stores info on how many times a particular link has been clicked and it contains a count column and the link_id column. What would be the query to the table in order to retrieve all the links along with the info? ...

how to cache latest inserted data in MySQL?

Is it possible to cache recently inserted data in MySQL database internally? I looked at query cache etc (http://dev.mysql.com/doc/refman/5.1/en/query-cache.html) but thats not what I am looking for. I know that 'SELECT' query will be cached. Details: I am inserting lots of data to MySQL DB every second. I have two kind of users for ...

Retrieve individual values along with their sum?

I have a table that contains link_ids that relate to another table; and this table has column titled ammount that stores values typed int. To retreive some total ammount along with individual values I query it as follows: SELECT ip, ammount, (SELECT SUM(ammount) FROM stats WHERE link_id = $link_id) as total_ammount FROM stats WHERE link...

Parsing a file of values in order to change into an SQL insert

Hey, trying to figure out a way to use a file I have to generate an SQL insert to a database. The file has many entries of the form: 100090 100090 bill smith 1998 That is,an id number, another id(not always the same), a full name and a year. These are all separated by a space. Basically what i want to to is be able to get variables f...

MS-Access -> SELECT AS + ORDER BY = error

Hello. I'm trying to make a query to retrieve the region which got the most sales for sweet products. 'grupo_produto' is the product type, and 'regiao' is the region. So I got this query: SELECT TOP 1 r.nm_regiao, (SELECT COUNT(*) FROM Dw_Empresa WHERE grupo_produto='1' AND cod_regiao = d.cod_regiao) as total ...

LINQ multiple childs in 1 row

My tables are structured as below: Questions id title 1 what is this? Answers id answer qid 1 an 1 I want to select the question and all the answers in one single row through LINQ? How can i do this? ...

How to use SQLConnect or SQLDriverConnect

Hello, I am trying to connect to a MS-SQL server on the internet. What should I put on the ServerName parameter of SQLConnect? I've tried this, but it fails: "DRIVER=SQL Server;SERVER=SERVER_IP;DATABASE=sales" SERVER_IP is something like 111.111.111.111,9999 EDIT: I followed Johns advice and here is my current code: SQLCHAR OutCon...

PHP MySql query to delete rows doesn't work.

I have this php script: foreach (get_all_topics () as $topic_id => $topic_info) { $result = mysql_query("DELETE FROM marks WHERE user_id = $user_id AND topic_id = $topic_id", $db); echo "DELETE FROM marks WHERE user_id = $user_id AND topic_id = $to...

DB2 Limit update access to one column in table

I have a DB2 table with column "comments" that I would like to allow a user to have update access to, without giving them update access to the whole table. I suspect that the answer will involve a view. However, in order to make the view relevant, won't I need to expose the primary key to the view? Won't the user then be able to update ...

How can I search for strings with characters not on the keyboard (non-english)?

I have a search form that I want my users to be able to enter English character equivalents for non-English characters. For example. To find Ælfred, the user could search for "Ælfred" or "AElfred". the search should also be case insensitive so "aelfred" would work. I also have it searching so that, by default, it matches the beginning o...

Mysql count id query

I'm using mysql table like this one: | userid | regdate | question | answer | ----------------------------------------------- 1 2010-10-14 question 1 answer1 2 2010-10-14 question 2 answer2 3 2010-10-15 question 3 answer3 4 2010-10-16 question 4 answer4 I want to count...

Number SQL rows based on query sorting?

Say I have a set of SQLite rows that have an auto increment field "_id", a string field "title", an integer field "type", and an integer field "number". There are only a few types (i.e. 1, 2, 3). All the number fields are currently blank, and I need to fill them with the numbers 1 through N for all rows of type 1. These numbers should ...

MySQL Count data for last 7 days

Hi, I have the following schema. Table votes +------------------+--------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+------+-----+---------------------+----------------+ | id | int(10)...

How best to block multiple "counts" on a counter?

I've got a real cheesy counter, just adds one to the counter field when a visit hits it. It's not counting page hits, but it's still cheesy. What I need to do is stop someone from just hitting refresh over and over. What's the simplest was to get this done? Cookies? I'd prefer not to log every visitor's ip address, etc... something sim...

MySql: convert a float to decimal produce more decimal number then the stored in back.sql file

Hi at all, i want to understand this: i have a dump of a table (a sql script file) from a database that use float 9,2 as default type for numbers. In the backup file i have a value like '4172.08'. I restore this file in a new database and i convert the float to decimal 20,5. Now the value in the field is 4172.08008 ...where come from the...

MySQL NOT IN Query problem

I am trying to search a table where the field name does not have a list of strings in it. I use: SELECT * FROM members WHERE name NOT IN ('bob', 'jim', 'leroy'); but it still returns matches containing those words. I have searched high and low for the answer to this. Can anyone help? ...