473,379 Members | 1,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Query Value from one table and insert into another table.

I wonder if possible on page load to query the value of a specific colmn and insert the result into another table. My query looks like so

[PHP]
<?
include("include/session.php");
?>
<?
$usr = "xxxx";
$pwd = "xxxxx";
$db = "xxxxx";
$host = "xxxxxx";

# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }

$result = mysql_query("INSERT INTO audio SELECT pid FROM pix WHERE username='$session->username'");

?>
[/PHP]

I guess the result I'm trying to acheive is that when the page is opened the above query is executed and the pid is queried base of username and inserted into the audio table. I'm not getting any error messages from the query but pid is not being inserted into the audio table..any ideas!
Jan 10 '07 #1
7 7203
subash
33
What is your version of MySQL?

Subash :)
Jan 10 '07 #2
subash
33
Hi,


Better do the following :

1. Select the value from the table and put into an recordset

2. Then insert the recordset value into the table

Subash :)
Jan 10 '07 #3
Hi,


Better do the following :

1. Select the value from the table and put into an recordset

2. Then insert the recordset value into the table

Subash :)
What is a recordset?
Jan 10 '07 #4
Okay I did a little research on the term and I'm kinda familiar with it now. When I get home I will create the recrord set query.. I will follow up latter..

Thanks you for the sugestion...
Jan 10 '07 #5
I've been hacking away at this for hours with no luck. Record set seem to be a little complicated for the task at hand.
Jan 11 '07 #6
Sorry for leaving this one open so long. This is another one solved. Thanks for the advice. But I found a better solution...
Jan 15 '07 #7
acoder
16,027 Expert Mod 8TB
Sorry for leaving this one open so long. This is another one solved. Thanks for the advice. But I found a better solution...
If it's possible, could you share the solution so it may help others in a similar situation. Thanks.
Jan 15 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jim | last post by:
Hi, I have a site with various parts which allow users to enter info via forms which gets entered into various tables in a MySQL db (I'm using ASP, rather than PHP). I have an ecards bit, and...
2
by: Iain | last post by:
Hi I have the following tables and stored procedure. I need to pass a value to the stored procedure and have it use the value in a query. After running that query it will return an ID which is...
4
by: Orion | last post by:
Hi, This is kind of last minute, I have a day and a half left to figure this out. I'm working on a project using ms-sqlserver. We are creating a ticket sales system, as part of the system, I...
5
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will...
7
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
8
by: Carl | last post by:
Hi, I hope someone can share some of their professional advice and help me out with my embarissing problem concerning an Access INSERT query. I have never attempted to create a table with...
2
by: Alex Scollay | last post by:
Let's say I have a column whose values are all 2-digit integers, e.g. 82 (though it's actually a varchar field). From now on, the column will be able to have 2-digit as well as 3-digit integers....
9
by: jardar.maatje | last post by:
I am logging scientific data. For this a normal relationship database is not idéal but I am going to try it. I have basically three tables like: datarecord: * idx - integer * time - datetime...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.