sql

Managing an unstable SQL connection on a Lotus Notes Agent

Hi, I have a working Lotus Notes agent. Running on LN 7. My agent runs every 5 minutes, and it sends some mails whenever it finds some specific records on an Microsoft SQL (2005) table. It usually works ok, but recently it stopped working -more than once now- and won't restart again until the Notes Server is restarted or the Notes admi...

Mysql table structure and designing

I have two tables both i am working like below concept... When any record will be inserted 'id' of first table ('id' is unique and auto_increment), I want to use this id value for further insertion in my second table (that means id will be foreign key).How should I should to design my table? If i am inserting values and further fetch...

Table with Select Statements, Executing Dynamic SQL and Returning Values

I have a select statement that returns a table full of SELECT statements (It goes through every column in every table and creates a select to find if that column contains any bad data). I need to take this table full of SELECT statements, execute them, and see if any of them return rows. If the count(*) > 0, then I want to print out ...

SQL REPLACE not working

There are only two columns and I want to UPDATE only if menu_id exists. Otherwise I want to insert a new row. Here's my query: REPLACE `dol_subs_menu_access` SET `menu_id` = '{$aVars['menu_item']}', `mlevels` = '{$sMemLevels}' This creates a new row everytime. Is there something I'm missing? ...

Convert Coldfusion Error.DateTime to a normal format?

At my company we store the information gathered from our site wide error template, into the database, but because of the format of the error.datetime it is making hard for me to do any sql queries for different date ranges. Has anyone used some t-sql or coldfusion code to convert it to a mm/dd/yyyy format? Here is an example of the fo...

How to create a result set from a select query using multiple joins AND pull values from unlinked table where certain values exist

I have a table which contains values for a collection of data. The value field thus contains multiple types of data - dates, numbers, text. One of the fields in the collection is a lookup to another unlinked table. I can figure out the select for the collection but not how to also pull in the value from the unlinked table. SELECT DIST...

MySql: Simple Problem with Creating Tables & Foreign Keys

Hello people, I have problems with creating tables & foreign key. (errno:150) here is a screenshot Updated Image: http://img264.imagevenue.com/img.php?image=14866_db_122_223lo.jpg Maybe the problem is the database design. -- ----------------------------------------------------- -- Table `mydb`.`projekt_user` -- -----------------------...

Howto update duplicates in firebird?

Hi everyone. Searched google for "firebird update duplicates" and "firebird handle duplicate update" but did not get any stuff, that would solve my question; so i thought it would be a good idea to use this marvellous site for the first time :) So how do i achieve mysql's "INSERT INTO asdf (x,y,z) VALUES ('a',1,2) ON DUPLICATE KEYS UPDA...

Binding multiple textbox controls to database rows.

Hi Guys. I´m trying to store some parameters for my application on a database table. The table contains multiple rows which contains a Key -> Value relationships. On my windows forms program (written in C#) I have multiple controls that should allow the user to interact with the stored configuration on the database. For example, my dat...

How do I include the matched item from a list in a sub-select?

I'm not sure if I phrased that correctly but here's my dilemma. I inherited an application which needs to look up the company associated with each contact in a list. The way it is currently written the application queries the DB on the following: SELECT c.name FROM company c WHERE c.id = (SELECT u.company_id FROM u...

Rails - search records by group

Hi, I would like to construct a search query that groups the records by their 'tag' attribute, and finds a certain number of records for each tag group. My 'place' table is as follows: | ID | name | geom | rating_av | tag | There are four different tags that a place can be assigned - "city", "food", "hotel" and "attraction". I would ...

Delphi SQL insert into statement error

qryreg.SQL.Add('Insert into RegistreerTB'); qryreg.SQL.add('Name , Surname, E-mail, Password)'); qryreg.SQL.Add('Values ('+quotedstr(edtname.Text)+','+quotedstr(edtsname.Text)+','+quotedstr(edtemail.Text)+','+quotedstr(edtpassuse.Text)+')'); qryreg.ExecSQL ; qryreg.SQL.Text := 'Select * from RegistreerTB'; qryreg.Open ; This is the cod...

Regarding sharepoint and SQL data store

Hi There, I have to create a web form and store all kinds of data from the page, the data will be text, num, email and checkboxes. I have to store them in a database SQL. I have to deploy the same page in the sharepoint server and users will be able to use that page to fillin the details once the details are filled in it should be load...

How to join across polymorphic tables in one query?

Hi all, I have 2 polymorphic associations through which I need to query. I have a news_article table which has a polymorphic association to teams, players, etc. Those teams, players, etc have a polymorphic association to photos through phototenic. I need to find all articles that have at least one picture that is 500px wide. The Ar...

Opinions: SQL Statements, do you use table aliases?

One of the guys I work with has the following to say about using SQL aliases, and he just posted the following on reddit. What do you guys think, to alias or not to alias? .... So I've always been the odd man out of my with my dev team about how SQL should be written. I learned in school to use aliases, but I hate them personally. I f...

How to drop a unique constraint in Firebird

I have this table CREATE TABLE "VACCINE" ( "CVX" INTEGER, "CPT" CHAR(5), "SHORTNAME" VARCHAR(20), "FULLNAME" VARCHAR(256), "VTYPE" CHAR(1), UNIQUE ("CVX") ); but it turns out that CVX is not unique after all. How do I drop the unique constraint? I can get the name of the constraint like this select rdb$constraint_n...

Error compiling ACE report with multiple SELECT INTO statements

INFORMIX-SQL 4.10: OK, So after fixing the INTO TEMP syntax and using AS aliases, the ACE compiler complained about not having every single alias in a GROUP BY clause so I added it to each SELECT statement. However now I still get a GRAM ERR on the FORMAT statement (see updated code sample) database PAWNSHOP END define variable sfech...

Getting the visitors MAC Address using PHP and ipTables

Hey guys, I'm doing a project for class and the professor has asked me to store the visitors IP address and MAC address to my database when they log in. So far after hours of looking around I have been able to get the IP using PHP, but now I need to figure out how to get the MAC address. From my research I can see that using iptables i...

MySQL: Rewriting this subquery?

I am trying to build a new table such that the values in the existing table are NOT contained (but obviously the following checks for contained) in another table. Following is my table structure: mysql> explain t1; +-----------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default...

Insert a trailing space into a SQL Server VARCHAR column

I'm trying to insert trailing spaces into a VARCHAR(50) column and the SQL insert seems to be cutting them off. Here's my code: create table #temp (field varchar(10)); insert into #temp select ' '; select LEN(field) from #temp; Unfortunately, this returns a length of zero, meaning the ' ' was inserted as a ''. I need a blank space to ...