mysql

Looking for a Function that insert "Any" form values to mysql

I am Looking for a Function that insert "Any" form values to mysql , update or delete with php. (or can we do this with one function?) (not OOP) I have found a function here: example: get all fields of form and ınsert into database. Thanks in advance ...

Selecting financial values from db stored as text

I have some financial values stored as text in a mysql db. the significance of financial is that negative numbers are stored enclosed in paranthesis. is there a way to automatically get the numeric value associated with that text. (like '5' shoudl be retuned as 5 and '(5)' should be returned as -5) ...

How to set default date time as system date time in mysql

I am trying to set my columns default date time to system datetime. It shows me an error Invalid default value for 'InsertionDate' alter table `vts`.`tblpickpoint` add column `InsertionDate` datetime DEFAULT 'Now()' NULL after `PickPointLatLong` ...

How to check if an SQL query executed without error in ASP?

Here's my code: if Request.Form("authorize") <> "" and request.form("delete") <> "true" then post_ids = Request.form("authorize") ids = split(post_ids, ",") For i = LBound(ids) to UBound(ids) sql = "update tbl_comments set authorized = 'true' where comment_id = " & ids(i) pageDB.execute(sql) Next m...

Php/Mysql Simple survey

I want to make a little php poll. The script should ask the users a question they can only answer by numbers from 0-999. After pressing the submit button the data should be stored into mysql. So I just want to know how much users choosed the same number (in percent). It's a simple poll but I don't want any output to be shown. ...

What is the mysql equivalent of Sql Server's @@Identity and @@error and how to use try catch in mysql

I am looking for few global variable in mysql which are equivalent of sql server. I want the whole list eg. Sql Server Equivalent @@error --- @@Identity --- etc. Basically right now I want to know what are the equivalent variable of @@error and @@identity. But it will be helpfull if u could provide some other variable ...

Nested query to find details in table B for maximum value in table A

I've got a huge bunch of flights travelling between airports. Each airport has an ID and (x,y) coordinates. For a given list of flights, I want to find the northernmost (highest x) airport visited. Here's the query I'm currently using: SELECT name,iata,icao,apid,x,y FROM airports WHERE y=(SELECT MAX(y) FROM ...

text indexes vs integer indexes in mysql

Hey, I have always tried to have an integer primary key on a table no matter what. But now I am questioning if this is always necessary. Let's say I have a product table and each product has a globally unique SKU number - that would be a string of say 8-16 characters. Why not make this the PK? Typically I would make this field a uni...

Data not transfred from form to mysql table (updating of data is not happening)

Hi all and thanks in advance to all for this I tired and was unable to find the answer i am looking for an answer. my problem is that i am unable to update the values enterd in the form. I have attached all the files i'm using MYSQL database to fetch data. what happens is that i'm able to add and delete records from form using ajax an...

mysql help xml document

how do you import data from an xml document to mysql having difficulty do this does anyone know to do this ...

Advantages of using two tables instead of a column with 2 different values

Hello I'm creating a database structure. I have to store ingoing and outgoing messages and i'm wondering wich is the best way to do this. 2 separated tables or the same tables with an ENUM('in', 'out') column ? Any suggestion ? Thanks. ...

apostrophe in mysql/php

i'm trying to learn php/mysql. inserting data into mysql works fine but inserting those with apostrophe is generating an error. i tried using mysql_real_escape_string, yet this doesn't work. would appreciate any help. <?php include 'config.php'; echo "Connected <br />"; $auth = $_POST['author']; $quo = $_POST['quote']; $author...

Zend Server with xampp MySQL

I am running Zend Server,Zend Studio (Trial versions) on Ubuntu 9.10. I am also using xampp to do most of my development. I plan to use Zend Server only to do URL profiling to know function level performance of my code. Is it possible to configure Zend Server to use XAMPP's MySQL database instead of installing a new mysql instance for Ze...

MySQL - Join as zero if record Not IN

To explain by example, take two tables, A and B Table A id foo 1 x 2 y 3 z Table B id aid bar 1 3 50 2 1 100 An example join SELECT foo, bar FROM a, b WHERE a.id = b.aid; Garners a result of foo bar z 50 x 100 What I would like to do is get all values of foo and for any instances where there isn't a...

Managing Foreign Keys

So I have a database with a few tables. The first table contains the user ID, first name and last name. The second table contains the user ID, interest ID, and interest rating. There is another table that has all of the interest ID's. For every interest ID (even when new ones are added), I need to make sure that each user has an entr...

MySQL Order By Problem, Why is 1000 being seen as Smaller than 2?

I have a strange problem, I am trying to order the output of a set of records by a field called displayOrder. Now even though record A has a displayOrder of 2 and record B has a displayOrder of 1000, record B still shows up before record A. Here's my select statement: SELECT * FROM items ORDER BY displayOrder ASC It works fine until ...

a bugging query

i need to get a query where the elements are displayed in case the first letter is E (the word is electronics).. i have tried with the following : mysql_query("select * from nested_category where name like '[A-F]%'"); Edit : its like i need to choose all the elements for which the first element lie between A & F .. I need all the ele...

GROUP BY as a way to pick the first row from a group of similar rows, is this correct, is there any alternative?

I have a table which stores test results like this: user | score | time -----+-------+------ aaa | 90% | 10:30 bbb | 50% | 9:15 *** aaa | 85% | 10:15 aaa | 90% | 11:00 *** ... What I need is to get the top 10 users: user | score | time -----+-------+------ aaa | 90% | 11:00 bbb | 50% | 9:15 ... I've come up w...

Update multiple rows with known keys without inserting new rows if nonexistent keys are found

Hello, Let's imagine that we have table items... table: items item_id INT PRIMARY AUTO_INCREMENT title VARCHAR(255) views INT Let's imagine that it is filled with something like (1, item-1, 10), (2, item-2, 10), (3, item-3, 15) I want to make multi update view for this items from data taken from this array [item_id] => [views] '1...

Sorting by value with ORDER BY?

For clarification, are you able to use MySQL this way to sort? ORDER BY CompanyID = XXX DESC What I am trying to do is use one sql query to sort everything where X = Y, in this case, where CompanyID = XXX. All values where CompanyID is not XXX should come after all the results where CompanyID = XXX. I don't want to limit my query but...