Joining 3 tables in MySQL using PHP
Hi,
I have the following 3 sample tables:
First
idkey
fk_second_idkey
fk_third_idkey
Second
idkey
Third
idkey
My SQL is
SELECT * FROM First INNER JOIN Second ON First.fk_second_idkey = Second.idkey INNER JOIN Third First.fk_third_idkey = Third.idkey AND First.fk_second_idkey = 2;
It compiles and I get a result set, but its repeated, so if i get back records 2, 3 and 4, the page will show 2, 3 and 4 about 3 times.
Can anyone assist with the above SQL?
Thanks.
Just kind of guessing at what you're trying to do, but if you want it grouped by the first table (one result per first table ID), then something like:
SELECT * FROM First
INNER JOIN Second
ON First.fk_second_idkey = Second.idkey
INNER JOIN Third
ON First.fk_third_idkey = Third.idkey
AND First.fk_second_idkey = 2
GROUP BY First.idkey;
...but I'm unclear on what's happening already and what you need it to do. Are the linked tables a one-to-one relationship? one-to-many?
Similar Messages
-
A Fluid Gallery from MySQL using PHP and various column widths
I have decided to try the new Fluid Layout option in Dreamweaver. I pull information from a database (MySQL) and use php to present it.
To show a gallery, I would pull the info and use the repeater code, and something like Tom Muck's horizontal repeater script to create a gallery. The images need to be shown with other text-based information (not just a caption). However, the HR script is a set amount of columns - and I want the number of columns to change depending on the width of the browser.
So it's more than just a gallery - pulling images from a database with Title = "x" these would be a repeated stylised DIV with multiple texts fields and styles within.
Let's take the example of a car dealership website it must show the car image, year, prices, description etc all in different style fonts so it can just be a caption to the image.
So the options are:
A fixed number of columns for each width: Monitor 5, Tablet 3, Mobile 1. Can this be achieved by having a "IF" statement in the actual code, if width = x use this version of the Horizontal Repeater?
A fluid version that has 6 columns and as you slide the browser's width you can see the gallery's width has less columns until it reaches 1 for mobile.
The fluid version would be better.
Any links to a tutorial or example would be most appreciated.
Many thanks
HVRThe only issue with using <divs> instead of a table to create your grid columns is that you will have to set a minimum height on the <divs> to keep them all at the same depth,much like a table cell construction looks and behaves. If you don't set a minimum height the grid will look all ragged PLUS the very big drawback is the <divs> won't clear if another <div> has more content in it which is going to happen if you include a 'description' of the car as this will never be the same length unless you are prepeared to edit the text.
See fluid sample below: You can just populate the <divs> from your database and loop through them
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled Document</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: verdana;
font-size: 13px;
#pageWrapper {
width: 98%;
max-width: 980px;
margin: 0 auto;
overflow: hidden;
.imageDetails {
width: 22.5%;
float: left;
margin: 0 0 15px 2%;
background-color: #CCC;
padding: 8px 0;
min-height: 200px;
dl {
margin: 0 8px;
padding: 0;
dt {
float: left;
width: 50%;
padding: 0 0 5px 0;
dd {
text-align: right;
padding: 0 0 5px 0;
h3 {
font-size: 13px;
margin: 0;
padding: 8px 8px 5px 8px;
p {
margin: 0;
padding: 0 8px;
@media screen and (max-width: 760px) {
.imageDetails {
width: 30%;
float: left;
margin: 0 0 15px 2%;
background-color: #9F3;
@media screen and (max-width: 480px) {
.imageDetails {
width: 45%;
float: left;
margin: 0 0 15px 2%;
background-color: #FC9;
@media screen and (max-width: 320px) {
.imageDetails {
width: 100%;
float: none;
margin: 0 0 15px 0;
background-color: #9CC;
</style>
</head>
<body>
<div id="pageWrapper">
<div class="imageDetails">
<img src="cars/car_1jpg" alt="">
<dl>
<dt>Price</dt>
<dd>£8500</dd>
<dt>Year</dt>
<dd>2009</dd>
</dl>
<h3>Description</h3>
<p>This is a description about the car</p>
</div>
<!-- end imageDetails -->
<div class="imageDetails">
<img src="cars/car_1jpg" alt="">
<dl>
<dt>Price</dt>
<dd>£8500</dd>
<dt>Year</dt>
<dd>2009</dd>
</dl>
<h3>Description</h3>
<p>This is a description about the car</p>
</div>
<!-- end imageDetails -->
<div class="imageDetails">
<img src="cars/car_1jpg" alt="">
<dl>
<dt>Price</dt>
<dd>£8500</dd>
<dt>Year</dt>
<dd>2009</dd>
</dl>
<h3>Description</h3>
<p>This is a description about the car. This is a description about the car. This is a description about the car.</p>
</div>
<!-- end imageDetails -->
<div class="imageDetails">
<img src="cars/car_1jpg" alt="">
<dl>
<dt>Price</dt>
<dd>£8500</dd>
<dt>Year</dt>
<dd>2009</dd>
</dl>
<h3>Description</h3>
<p>This is a description about the car</p>
</div>
<!-- end imageDetails -->
<div class="imageDetails">
<img src="cars/car_1jpg" alt="">
<dl>
<dt>Price</dt>
<dd>£8500</dd>
<dt>Year</dt>
<dd>2009</dd>
</dl>
<h3>Description</h3>
<p>This is a description about the car</p>
</div>
<!-- end imageDetails -->
</div>
</body>
</html> -
Error while importing the tables from MySQL using the data source connection
Hi,
I am trying to import tables from MySQL into Powerpivot using the data source connection, if use the import using the Query option its working fine but not with the select list of table option.
when i click on the select list of tables option, i get the below error after selecting all the tables to be imported:
OLE DB or ODBC error.
An error occurred while processing table 'XXXXXXXXXX'.
The current operation was cancelled because another operation in the transaction failed.Hi Bharat17an,
Please provide the detail information when create the MySQL connection in your PowerPivot model. Here is a good article regarding "how to Use MySQL and Microsoft PowerPivot Together" for your reference, please see:
http://www.datamensional.com/2011/09/how-to-use-mysql-and-microsoft-powerpivot-together-2/
If this issue still persists, please help to collection windows event log information. It maybe helpful for us to troubleshoot this issue.
Regards,
Elvis Long
TechNet Community Support -
Could not able to join physical tables in obiee using a dataconversion func
Hi,
i am trying to join physical tables wc_perf_ratings_d and w_wrkfc_evt_month_f with condition as
"Oracle Data Warehouse"."Catalog"."dbo"."Dim_WC_PERF_RATINGS_D"."RATING_CD" = to_char(round( "Oracle Data Warehouse"."Catalog"."dbo"."Fact_W_WRKFC_EVT_MONTH_F"."ORIG_PERF_RATING",2)). But i am getting the below syntax error while applying this.
[nQSError:27002] Near <(>: Syntax error [nQSError:26012]
i used the same condition on database and i got results.
select rating_cd,
to_char(round(orig_perf_rating,2)) as orig_perf_rating,
headcount,
fte,
salary_annl,
total_service_days
from wc_perf_ratings_d, w_wrkfc_evt_month_f
where wc_perf_ratings_d. rating_cd= to_char(round(w_wrkfc_evt_month_f.orig_perf_rating,2));
Here i am trying to convert the format of ORIG_PERF_RATING field and trying to join with RATING_CD in physical layer.
so my question is, is it possible to join in obiee using such conditions? i do not want to convert the field format in ETL and i wanted to do that at obiee level. Could anybody please suggest how to do it?Hi,
Thanks for the link. i was trying another method in joining the two fields (rating_cd, orig_perf_rating) at database level. As i said both these fields are of varchar datatype. Earlier i tried to convert orig_perf_rating field from number to string. But i want to convert string data in (rating_cd) to number. so i have values in it like (1,2,3,4,bep, ep, vp, nr). Actually i have a requirement to create a database view for the dimension table (wc_perf_ratings_d) having rating_cd field with new datatype (number) instead of string and then join this field with orig_perf_rating in fact table which already has numbers. Along with the number rating fields, there are four particular string fields in rating_cd (bep, ep, vp, nr) as i mentioned. so while converting, i also have to convert these specific string fields in to partcular numbers. (bep=1, ep=5, nr=0, vp=3). Now, all this requirement is at database level as i am creating a db view. so my question is how to apply the to_number conversion function for converting the rating_cd field values (bep, ep, vp, nr) from string to specific mentioned numbers. Could you please help?
for eg: create or replace view as select to_number(rating_cd....................
Thank you. -
Import Excel to MySQL using PHP
Does anyone know the coding for if you have a excel document
that has the same headers as the mysql table, however, you wish to
import the data in excel inside your mysql table. How is this done
through PHP. I've seen a lot of coding to do the reverse by
exporting mysql data into excel. What I need is the reverse, is
this possible?
Thank you,
AdonaiEchadDoes anybody have an answer.
-
How can you upload an image to MYSQL using php?
Ok this is a joint thread with one of my other ones because no one else was posting on it, so I did not get what I needed, so, How can you upload an image to mysql so when some one logs on to my site, they see or can upload there own avatar, now there are loads of problems with this, 1) many people don't know how, 2) It's not every day you try to encode a image into mysql, 3) Letting people upload images into mysql can cause traffic problem with people trying to log in. So that's it.
Uploading images into MySQL is a bad idea, for more reasons than you mention. You should store the images in a directory on the server instead. But if you want to learn the hard way, here is the method:
The mysql data type must be blob.
The form enctype must be multipart, like this: enctype="multipart/form-data"
The form input field myst be type file, like this: <input type="file" name="upload"/>
Here is example code that prepares the variable $photodata to be inserted into the database.
$uploadfile = $_FILES['upload']['tmp_name'];
$photoname = $_FILES['upload']['name'];
$uploadtype = $_FILES['upload']['type'];
if ($uploadfile != "") {
$tempfile = fopen($uploadfile, 'rb');
$filesize=filesize($uploadfile);
$width=getimagesize($uploadfile);
$widthx=$width[0];
$heightx=$width[1];
if (($widthx > 102) or (heightx > 135)){
$image_too_big = " but the image size was too large and was not submitted.";
} else {
$photodata = fread($tempfile, filesize($uploadfile));
$photodata = addslashes($photodata); -
Can select, but cannot insert into oracle tables using php.
I am having trouble inserting data into a tables in oracle using PHP. I can insert into the tables using baninst1, but nothing else. I can't even insert using the tables' owner. Every time I try I get the ORA-00492 error of table or view does not exist. However, I can run a select statement just fine. So far, baninst1 is the only user that can actually do inserts. I've triple checked all the table grants and everything is fine. Also, I can copy/paste the exact insert statement into SQL*Plus and it works with the correct user. It doesn't have to be baninst1. I've tried everything I can think of. I've tried putting the table name in quotes, adding the schema name to the table, checking public synonyms, but everything appears to be ok. I would greatly appreciate any suggestions others may have.
I'm using PHP 5.2.3 with an oracle 9i DB.Here is the code that doesn't work. It works only with baninst1, no other username will work and all I do is change the my_username/my_password to something different. This is one example function where I try to do an insert, but it doesn't work on any of the tables I try.
Thanks for looking.
class Oracle {
private $oracleUser = "my_username";
private $oraclePassword = "my_password";
private $oracleDB = "MY_DB";
private $c = null;
function Connect() {
if ( !($this->c = ocilogon( $this->oracleUser, $this->oraclePassword, $this->oracleDB ) ) )
return false;
return true;
function AddNewTest($testName, $course, $section, $term, $maxAttempts, $length, $startDate, $startTime, $endDate, $endTime)
$result = "";
if( $this->c == null )
$this->Connect();
$splitIndex = strpos($course, " ");
$subjectCode = substr($course, 0, $splitIndex);
$courseNumber = substr($course, $splitIndex + 1);
$insertStatment = "insert into szbtestinfo(szbtestinfo_test_name,
szbtestinfo_course_numb,
szbtestinfo_section,
szbtestinfo_max_attempts,
szbtestinfo_length_minutes,
szbtestinfo_start,
szbtestinfo_end,
szbtestinfo_id,
szbtestinfo_subj_code,
szbtestinfo_eff_term)
values( '" . $testName .
"', '" . $courseNumber .
"', '" . $section .
"', " . $maxAttempts .
", " . $length .
", to_date('" . $startDate . " " . $startTime . "', 'MM/DD/YYYY HH24:MI')" .
", to_date('" . $endDate . " " . $endTime . "', 'MM/DD/YYYY HH24:MI')" .
", szsnexttest.nextval" .
", '" . $subjectCode .
"', '" . $term . "')";
//return $insertStatment;
$s = OCIParse($this->c, $insertStatment);
try
$result = OCIExecute($s);
catch(exception $e)
return $result;
} -
How to create a table in mysql tool kit
Hello Sir/Madam,
H
How to create a table in mysql using the labview tool kit,,,I need the hyperlink to download this tool kit,
Thanks and regards
Jack
Jayavelquick search
study and ask if further specific help needed -
Using a view to join two tables
Thank you in advance for any advice you can lend.
I am using this code in my MySQL db to create a view.
select
job.id as job_id,
umr_cost_calculation.plant_name,
max(umr_cost_calculation.id) as max_id
from
job,
umr_cost_calculation
where
job.id = umr_cost_calculation.job_id
group by job.id , umr_cost_calculation.plant_name
I did this so I can join two tables and pull in the most current cost data for a specific plant. The report will, at times, show the wrong (older) data. I can re-run the report, filter to just the one job and see again the wrong data. When I add the max_id to the report, it display the id and updates the report with the correct data. It appears that the view was stale and by adding the ID to the report this fixed the issue.
1) Is this the best way to make this join? I don't see how Crystal supports a subquery to make a join (this is why I used the view).
2) If I leave the max_id on the report, will this force the view to always update?Try:
Select
D1.EmpLoginID,
Count(D1.ID),
Count(D1.AlarmCode),
D1.EmpName,
D1.EmpAddress,
D2.Db2Count
FROM DB1.Data D1
LEFT JOIN (SELECT
empLoginID, Count(*) as Db2Count
FROM DB2.ALL_Database
WHERE site = 'Atlanta'
GROUP BY empLoginID
) D2
ON D1.EmpLoginID = D2.EmpLoginID
GROUP BY D1.empLoginID, D1.EmpName, D2.EmpAddress, D2.Db2Count
Order BY D1.empLoginID ASC
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Populate Livecycle PDF from mySQL database using PHP
I'm trying to set up a database of loan agreements, where users will submit a form through Acrobat and their information will be stored in a mySQL database. Later, they can go back and download the PDF, which will be repopulated with their data in the mySQL db.
I made the form in Livecycle Designer and submit the information through HTTP POST. I can easily get the information from the form into the database...my only problem is getting that information back out into the PDF.
What would allow me to write back to the PDF, preferably using PHP? What kind of syntax would that require?
Thanks!I have a vital form that clients fill out, which is passed to many people in the company along the workflow. The form is a Planner and we have in the following PDF, Word Doc..
Well before, the Planner.pdf was originally created in Word, since most people have access to Word.. but evolved to a PDF form created from the Word Doc via Adobe LiveCycle Designer 8.0 w/ User Rights enabled so that the form could be filled out and saved using Adobe Reader.. which was a step better than Word.. being that it is free. But this needed to be easier and more to the point b/c some clients don't particularly like installing the latest version of Reader, even if you provide them the link. Nor do they like saving the form, filling the form, and attaching the form to send back.
My goal is to have the client fill an HTML version of the form, submit and be done with it, but everyone in the workflow be able to easily receive the filled Planner as a PDF form.
So some months ago I ran into this post Chris Trip, "Populate Livecycle PDF from mySQL database using PHP" #8, 22 Sep 2007 4:37 pm
which uses the command line Win32 pdftk.exe to merge an FDF file into an existing PDF on the remote server, and serve this to whoever.
My problem was with shared hosting and having the ability to use the Win32 pdftk.exe along with PHP which is predominantly used on Linux boxes. And we used a Linux box.
so i created the following unorthodox method, which a client fills the HTML version of the Planner, all field values are INSERTED into a table in MySQL DB, I and all filled planners that have been filled by clients to date can be viewed from a repository page where an XML file is served up of the corresponding client, but someone would have to have Acrobat Professional, to import the form data from the XML file into a blank form.. altoughh this is simple for me.. I have the PHP file already created so that when a Planner is filled and client submits. >> the an email is sent to me with a table row from the repository of the client name, #, email, and a link to d-load the XML file,
But I also have the PHP files created so that the Planner can be sent to by email to various people in the workflow with certain fileds ommitted they they do not need to see, but instead of the XML file beiong served up i need the filled PDF Planner to be served.
I can do this locally with ease on a testing server, but I am currently trying to use another host that uses cross-platform compatibility so i can use PHP and the pdftk.exe to achieve this, as that is why I am having to serve up an XML file b/c we use a Linux server for our website, and cant execute the exe.
Now that I am testing the other server (cross-platform host), just to use them to do the PDF handling (and it's only $5 per month) I am having problems with getting READ, WRITE, EXECUTE permissions..
Si guess a good question to ask is can PHP do the same procedure as the pdftk.exe, and i can eleminate it.
or how in the heck can i get this data from the DB into a blank PDF form, like i have described??
here are some link to reference
Populating a LiveCycle PDF with PHP and MySQL
http://www.andrewheiss.com/Tutorials?page=LiveCycle_PDFs_and_MySQL
HTML form that passed data into a PDF
http://www.mactech.com/articles/mactech/Vol.20/20.11/FillOnlinePDFFormsUsingHTML/index.htm l
and an example
http://accesspdf.com/html_pdf_form/ -
I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
[ABCTABLE]
ABCORDER
ABCPART
ABCSERIAL
ABCDATE
[ZYXTABLE]
XYZORDER
XYZPART
XYZSERIAL
XYZDATE1
XYZDATE2Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
on this computer. There are no "Null" fields in either of the tables.
This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
[MSORDR]
MSORDER
MSPART
MSSERIAL
MSOPNDATE
11111111
4444444
55555
2/4/2015
22222222
6666666
11111
1/6/2015
33333333
6666666
11111
3/5/2015
This table has one order for every part number and every serial number.
[GLORDR]
GLORDER
GLPART
GLSERIAL
GLSTARTDATE
GLENDDATE
ABC11111
444444
55555
1/2/2015
4/4/2015
ABC22222
666666
11111
1/5/2015
4/10/2015
AAA11111
555555
22222
3/2/2015
4/10/2015
Post Query table
GLORDER
MSORDER
GLSTARTDATE
GLENDDATE
MSOPNDATE
ABC11111
11111111
1/2/2015
4/4/2015
2/4/2015
ABC22222
22222222
1/5/2015
4/10/2015
1/6/2015
ABC22222
33333333
1/5/2015
4/10/2015
3/5/2015
This is the SQL minus the between date join.
SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART); -
How to use one form to submit data to 2 tables on mysql
Can someone please help me on this,
I am developing a jsp website and I want to use one form to submit data to 4 tables on mysql database and the tables are related by one foreign key.
Can someone bail me out of this ....I've hit a hard brick wall!!!!...kwesij wrote:
Can someone please help me on this,
I am developing a jsp website and I want to use one form to submit data to 4 tables on mysql database and the tables are related by one foreign key.
Can someone bail me out of this ....I've hit a hard brick wall!!!!...What's the problem? What does a brick wall look like?
Connect to the database and execute four SQL INSERT/UPDATE statements as a single unit of work. The fact that you have one form shouldn't be an issue.
I'll bet you're having trouble because you haven't layered the problem either in code or in your mind.
I'd recommend that you write a POJO to take in some objects and execute the SQL. Once you have that running successfully you can worry about the form. Decouple the two.
Computer science is all about decomposing large problems into smaller ones.
% -
Using functions in select statement(joining 5 tables) taking long time in Oracle
Hi,
I have created a query in oracle which joins 5 tables and uses two functions(function names are 'ca_concat' and 'ca_concat_noseq').
Query takes approximately 40 secs to execute around 12000 records. If I remove the functions from query it excutes within a second..
Note : I have used the oracle SQL Developer for testing the query.
It would be appriciated if anybody helps me to improve the perfomance of the query.
Below are the querie with and without functions:
1. Query with functions:
select
imsAuditEvent12.id as ID,
imsAuditEvent12.audit_time as AUDIT_TIME,
imsAuditEvent12.admin_dn as ADMIN_DN,
imsAuditEvent12.admin_name as ADMIN_NAME,
imsAuditEvent12.event_name as EVENT_NAME,
imsAuditEvent12.event_description as EVENT_DESCRIPTION,
imsAuditEvent12.event_state as EVENT_STATE,
imsAuditEvent12.envname as ENVNAME,
imsAuditTaskSession12.task_name as TASK_NAME,
imsAuditTaskSession12.id as TASK_ID,
imsAuditTaskSession12.task_description as TASK_DESCRIPTION,
imsAuditTaskSession12.task_priority as TASK_PRIORITY,
S1.OBJECT_ID,
S1.OBJECT_NAME as OBJECT_NAME,
S1.OBJECT_TYPE as OBJECT_TYPE,
S2.ATTRIBUTE_NAME as ATTRIBUTE_NAME,
S2.ATTRIBUTE_OLDVALUES as ATTRIBUTE_OLDVALUES,
S2.ATTRIBUTE_NEWVALUES as ATTRIBUTE_NEWVALUES,
S3.OBJECT_DN as OBJECT_DN,
S3.OBJECT_TYPE as IMSOBJECT_TYPE,
S3.CONTAINER_NAME as CONTAINER_NAME,
S3.CONTAINER_DN as CONTAINER_DN,
S3.CONTAINER_TYPE as CONTAINER_TYPE
from
imsAuditEvent12 LEFT JOIN imsAuditTaskSession12 ON imsAuditTaskSession12.id=imsAuditEvent12.tasksession_id LEFT JOIN
(select parent_event_id,
ca_concat('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.object_name','imsAuditEventObject12') as OBJECT_NAME,
ca_concat('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.object_type','imsAuditEventObject12') as OBJECT_TYPE,
ca_concat_noseq('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.ID','imsAuditEventObject12') as OBJECT_ID
from
imsAuditEventObject12 group by parent_event_id) S1
ON imsAuditEvent12.id = S1.parent_event_id LEFT JOIN
(select
parent_object_id,
ca_concat('parent_object_id',parent_object_id,'attribute_name','imsauditobjectattributes12') as ATTRIBUTE_NAME,
ca_concat('parent_object_id',parent_object_id,'attribute_oldvalue','imsauditobjectattributes12') as ATTRIBUTE_OLDVALUES ,
ca_concat('parent_object_id',parent_object_id,'attribute_newvalue','imsauditobjectattributes12') as ATTRIBUTE_NEWVALUES
from
imsauditobjectattributes12 group by parent_object_id) S2
ON S1.OBJECT_ID = S2.parent_object_id LEFT JOIN
(select
parent_event_id,
ca_concat('parent_event_id',parent_event_id,'OBJECT_DN','imsauditobjectrelationship12') as OBJECT_DN,
ca_concat('parent_event_id',parent_event_id,'OBJECT_TYPE','imsauditobjectrelationship12') as OBJECT_TYPE ,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_NAME','imsauditobjectrelationship12') as CONTAINER_NAME,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_DN','imsauditobjectrelationship12') as CONTAINER_DN,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_TYPE','imsauditobjectrelationship12') as CONTAINER_TYPE
from
imsauditobjectrelationship12 group by parent_event_id) S3
ON imsAuditEvent12.id =S3.parent_event_id where imsauditevent12.id > 0 and imsauditevent12.id <12000 order by imsauditevent12.id ASC;
2. Query without using functions:
select * from imsauditeventobject12 left join imsauditevent12 on imsauditeventobject12.id=imsauditevent12.id left join imsauditobjectattributes12 on imsauditeventobject12.id=imsauditobjectattributes12.parent_object_id left join imsaudittasksession12 on imsauditevent12.tasksession_id=imsaudittasksession12.id left join imsAuditObjectRelationship12 on imsAuditEvent12.id =imsAuditObjectRelationship12.parent_event_id where imsauditevent12.id >0 and imsauditevent12.id < 12000 order by imsauditevent12.id asc;
Thanks,
BadriHi,
Please find the below more information about the query.
DB version: Oracle 11g Enterprise Edition Release 11.2.0.1.0
Below are source of the functions:
create or replace function ca_concat( ca_key_name in varchar2,
ca_key_val in varchar2,
ca_other_col_name in varchar2,
ca_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str varchar2(32000);
l_sep varchar2(1);
l_val varchar2(32000);
l_count number(6);
l_cur rc;
begin
l_count :=1;
l_str := '';
open l_cur for 'select '|| ca_other_col_name ||'
from '|| ca_tname || '
where ' || ca_key_name || ' = '
using ca_key_val;
loop
fetch l_cur into l_val;
l_val := SUBSTR(l_val,0,102);
exit when (l_cur%notfound or l_count > 38);
l_str := l_str || l_sep || l_count || '.' || l_val;
l_sep := ',';
l_count := l_count + 1;
end loop;
close l_cur;
return l_str;
end;
create or replace function ca_concat_noseq( ca_key_name in varchar2,
ca_key_val in varchar2,
ca_other_col_name in varchar2,
ca_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str nvarchar2(32000);
l_sep varchar2(1);
l_val varchar2(32000);
l_count number(6);
l_cur rc;
begin
l_count :=1;
open l_cur for 'select '||ca_other_col_name||'
from '|| ca_tname || '
where ' || ca_key_name || ' = '
using ca_key_val;
loop
fetch l_cur into l_val;
exit when (l_cur%notfound or length(l_val)>3000 or l_count>1);
l_str := l_str || l_sep || l_val ;
l_sep := ',';
l_count := l_count + 1;
end loop;
close l_cur;
return l_str;
end;
Below are the tables structures:
DESC imsauditevent12;
Name Null Type
ID NOT NULL NUMBER
TASKSESSION_ID NOT NULL NUMBER
TASKSESSION_OID VARCHAR2(100)
PARENT_EVENT_OID VARCHAR2(100)
AUDIT_TIME NOT NULL TIMESTAMP(6)
EVENT_OID NOT NULL VARCHAR2(100)
ADMIN_DN NOT NULL VARCHAR2(512)
ADMIN_NAME VARCHAR2(255)
EVENT_NAME NOT NULL VARCHAR2(255)
EVENT_DESCRIPTION VARCHAR2(4000)
EVENT_STATE VARCHAR2(100)
ENVNAME NOT NULL VARCHAR2(100)
ENV_OID NOT NULL VARCHAR2(100)
DESC imsauditeventobject12;
Name Null Type
ID NOT NULL NUMBER
PARENT_EVENT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
OBJECT_TYPE NOT NULL VARCHAR2(100)
OBJECT_NAME VARCHAR2(255)
DESC imsauditobjectattributes12;
Name Null Type
ID NOT NULL NUMBER
PARENT_OBJECT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
DISPLAY_NAME VARCHAR2(255)
ATTRIBUTE_NAME NOT NULL VARCHAR2(255)
ATTRIBUTE_OLDVALUE VARCHAR2(4000)
ATTRIBUTE_NEWVALUE VARCHAR2(4000)
DESC imsaudittasksession12;
Name Null Type
ID NOT NULL NUMBER
PARENT_TS_OID VARCHAR2(100)
PARENT_EVENT_OID VARCHAR2(100)
AUDIT_TIME NOT NULL TIMESTAMP(6)
TASKSESSION_OID NOT NULL VARCHAR2(100)
ADMIN_DN NOT NULL VARCHAR2(512)
ADMIN_NAME VARCHAR2(255)
TASK_NAME VARCHAR2(255)
TASK_TAG NOT NULL VARCHAR2(255)
TASK_DESCRIPTION VARCHAR2(4000)
TASK_PRIORITY NUMBER
STATE NOT NULL VARCHAR2(100)
ENVNAME NOT NULL VARCHAR2(100)
ENV_OID NOT NULL VARCHAR2(100)
DESC imsAuditObjectRelationship12;
Name Null Type
ID NOT NULL NUMBER
PARENT_EVENT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
OBJECT_TYPE NOT NULL VARCHAR2(100)
OBJECT_DN NOT NULL VARCHAR2(512)
CONTAINER_TYPE NOT NULL VARCHAR2(100)
OBJECT_NAME NOT NULL VARCHAR2(255)
CONTAINER_NAME NOT NULL VARCHAR2(255)
CONTAINER_DN NOT NULL VARCHAR2(512)
OPERATION NOT NULL VARCHAR2(50)
Thanks,
Badri -
How do you join two tables from different Oracle schemas using a subquery
I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
The query is as follows:
sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
+ "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
+ "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
+ "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
The format of the query is copied from a SQL programming manual.
I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
Edited by: user11338343 on Oct 19, 2009 6:55 AMI believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
If you want to do a straight join without a subquery you could do the following
SELECT DD_12809.PDTABLE_12_1.LINE_ID
, FAB.MAT_DESCRIPTION
FROM DD_12809.PDTABLE_12_1
JOIN RA_12809.PDTABLE_201 AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS HTH! -
Using MySql and PHP with Dreamweaver on a Mac
Hello all,
As always if the answers to these questions are obscenely
obvious please humour me.
I use XHTML and CSS in my websites and realise that it is
time that I dabbled with SSI. So I've started using PHP.
However, I have been following the installation directions of
MySql and am running into problems. I am installing the relavent
software and am then unable to find it on my Mac, the startup files
are there but the actual MySql data appears to not be installed
despite my computer telling me it is...... I am using a G3 running
OSX 10.4 is this good enough? I noticed talk of needing a PowerPC
or Intel mac. Is this the case?
Also, would I need MySql installed on my actual computer if
the my servers have it already? And does Dreamweaver 8 have both of
these programs installed as standard?
If you could help out I would be very appreciative as I would
like to learn this stuff and I appear to be struggling at the
outset....
Cheers
M.AM.A.Wilson wrote:
> However, I have been following the installation
directions of MySql and am
> running into problems. I am installing the relavent
software and am then unable
> to find it on my Mac, the startup files are there but
the actual MySql data
> appears to not be installed despite my computer telling
me it is...... I am
> using a G3 running OSX 10.4 is this good enough? I
noticed talk of needing a
> PowerPC or Intel mac. Is this the case?
MySQL is a relational database management system that
comprises a
database server and several utility programs. Although you
install it
like any other program on a Mac, the similarity stops there.
First, the point about PowerPC and Intel Macs is that there
are
different versions of the MySQL installer for each type of
processor.
I'm pretty sure that a G3 is OK, but you must choose the
PowerPC version
of MySQL, not the 64-bit or x86 (Intel Mac) version.
Once you have installed MySQL, you need to drag the
MySQL.PrefPane icon
from the disk image onto your System Preferences. This
installs a
Preference Pane that enables you to start and stop MySQL. The
Preference
Pane has an option to start up MySQL automatically, but in my
experience, it doesn't work on Tiger. You need to open the
Preference
Pane, and click Start MySQL Server each time you start your
computer.
The best way to work with MySQL is to use a graphical
interface, such as
phpMyAdmin. As Osgood has mentioned, I have written a book
about PHP and
Dreamweaver, which goes into all the necessary details. It's
also very
Mac-friendly with separate instructions where necessary for
PC and Mac.
More details here:
http://foundationphp.com/dreamweaver8/
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Maybe you are looking for
-
My Mac Pro Desk Top computer no longer can "see" my second display??
I've tried reversing the connections on the back of the MacPro but it still doesn't "see" the second display. I've had these two displays hooked up for years with no problems. I recently upgraded to Mountain Lion and I just had the MacPro in the Ap
-
Handshake between tomcat and sap xi over https
I have a webservice which is hosted on sap xi server. My class in tomcat will call it over https protocol. For that, tomcat needs to import the xi certificate. I did it in cacerts which resides in jre's lib/security directory. Still, it doesn't work.
-
TFTP file too large for upload
I'm trying to upgrade my router via TFTP. I keep getting this File too large for TFTP error. I'm using the recommended TFTP server from Solarwinds. There does not seem to be any setting in the server to let large file pass, It's the first time I see
-
Error -51, Can't save to disk
Ibook G3 700 12inch running 10.4 Getting error message when I try to save, duplicate an icon, any writing to disk. Computer still works in every other way. "Sorry, the operation could not be completed because an unexpected error occured (Error code -
-
i had homesharing on my mac, but when i tried to watch a rented movie on my apple tv i got a message to turn on homesharing. i tried but kept getting an error message 12004. can anyone please provide a solution ?