helps the inner join

Hi all

I am trying to learn something new, and I'm having a little difficulty.  I'm trying to learn more about inner joins.  I looked at countless books, tutorials, and all the rest have that I can find, but I can't seem to understand that.  Nothing I try works.

I have related tables, and I try to get the data to display.  I have the database set up as follows:

films (table name) has the movie_id, movie_name and movie_star_rating fields

family_rating (table name) has star_id, star_name, and star_file_name fields

in PHPMyAdmin, I had movies.movie_star_rating internally associated with family_rating.star_id

When I view the data, I'm pulling the table of movies, but instead of having a number, I would like to have displayed family_rating.star_name.  I have the following code to do this:

$query="SELECT * FROM movies
  INNER JOIN family_rating ON movies.movie_star_rating=family_rating.star_id 
  WHERE movies.movie_name_series='$search'";

$result= mysql_query($query)or die (mysql_error());

while($row=mysql_fetch_array($result)){

// Display the data 

 echo $row['movies.movie_name'];
 echo $row['family_rating.star_file_name'];
}


Can someone let me know what I am doing wrong?  Thanks for your help.

$query = "SELECT * FROM movies, family_rating"
INNER JOIN family_rating ON movies.movie_star_rating = family_rating.star_id
WHERE movies.movie_name_series = '$search';

OK, that SQL is not the same as your original post.

> Not unique table/alias: 'family_rating '.

This tells us what's wrong. You specify the two tables after the from clause. Try again with your original query:

$query = "SELECT * FROM movies"
INNER JOIN family_rating ON movies.movie_star_rating = family_rating.star_id
WHERE movies.movie_name_series = '$search';

Tags: Dreamweaver

Similar Questions

  • Help with Inner join problem

    The following query works fine as long as there is a value in the subID field, which is the end of the inner join statement. If the subID is empty then no data is output, even if it is there. Try as I may, I can't do the right solution in which the statement to get the data to show without the subID. What Miss me?

    < name cfquery = "getInfo" datasource = "#application.database #" >

    Select page_id, pageName, pages.content, pages.cat_id, pages.seo_title, pages.seo_desc, pages.seo_words, pages.h1_title, pages.pic, pages.brochure, pa ges.video, catagories.catagory, subcat.subID, subcat.sub_category

    (page INNER JOIN categories ON pages.cat_id = catagories.cat_id) INNER JOIN subcat ON pages.subID = subcat.subID

    where pages.page_id = #page_id #.

    < / cfquery >

    Rick,

    Looks like you need a LEFT OUTER join to the table "subcat", so that all the records for the 'pages' and 'categories' are returned, even if no records matching "subcat" doesn't exist.  Joins INTERNAL returns only the selected records when both sides of the join statement tables have matching values, while you will get a join OUTER LEFT (sometimes also known simply as a LEFT JOIN) * everything * selected records from the table on the left side of the join statement, no matter if he adapt records from the table on the right side of the join statement.  When there is no corresponding record in the table on the right side of the join statement, all the columns in your SELECT clause that come from the table on the right side of the join statement will contain NULL values.

    HTH,

    -Carl V.

  • The first mention of an inner join of return?

    I searched all over the internet a response for that, but I had no luck so far.

    Select a.*, BOXES_TABLE a b.Part_Name
    inner join PARTS_IN_THE_BOXES_TABLE b on b.BOX_id = a.BOX_id I can modify only this line
    where a.BOX.id = 1234

    Anyway is to limit the inner join to return only one record? I can't use a where statement for her clause.

    I want to return a part name of the largest number in a box, but I can't seem to write a join that will not return everything in this area, because the only id I have is for boxes, and many parts may have the same id box.

    Some may show me this, I'll be the King of work tomorrow.

    You can encapsulate another query autour the big one scary? Something like:

    SELECT box_id, col2, col3, part_name
    FROM (SELECT box_id, col2, col3, part_name,
                 ROW_NUMBER() OVER(PARTITION BY box_id ORDER BY NULL) rn
          FROM (big scary query)
          WHERE box_id IN (b1, b2, b3))
    WHERE rn = 1
    

    This will return a "random" part in each area. If you have a preference for which part fate, try changing the ORDER OF NULL make favorite part come first in the list

    John

  • SQL JOIN. We'RE after or before the keyword JOIN later

    Hi guys,.

    I spotted a very unusual behavior that I can't explain.

    I've isolated the problem to the following joints.

    Why the second join returns no less line? Why the first JOIN causes more lines?

    LEFT OUTER JOIN DWH.SA_BEZ_SAS_GRUPPE_V stellwerkg
    INNER JOIN DWH.SA_STELL_V stellwerk
    WE (stellwerkg.owner_fid = stellwerk.fid)
    WE (stellwerkg.member_fid = vorsignal.fid)
    -5413 lines

    LEFT OUTER JOIN DWH.SA_BEZ_SAS_GRUPPE_V stellwerkg
    WE (stellwerkg.member_fid = vorsignal.fid)
    INNER JOIN DWH.SA_STELL_V stellwerk
    WE (stellwerkg.owner_fid = stellwerk.fid)

    -5411 lines

    Thanks for any clarification.

    very strange indeed - so we have:

    SQL > select / * normal ANSI syntax * /.

    2 count (*)

    3 from t1

    left outer join 4 t3

    5 we (t3.id = t1.id)

    inner join 6 t2

    7 on (t3.id = t2.id);

    COUNT (*)

    ----------

    10

    SQL > select / * strange ANSI syntax: predicate of order 1, 2 * /.

    2 count (*)

    3 from t1

    left outer join 4 t3

    inner join t2 5

    6 we (t3.id = t1.id)

    7 on (t3.id = t2.id);

    on (t3.id = t1.id)

    *

    FEHLER in line 6:

    ORA-00904: "T1". "" Id ": ungultiger Bezeichner

    SQL > select / * strange ANSI syntax: predicate of order 2, 1 * /.

    2 count (*)

    3 from t1

    left outer join 4 t3

    inner join t2 5

    6 we (t3.id = t2.id)

    7 on (t3.id = t1.id);

    COUNT (*)

    ----------

    15

    We get:

    • a result of 10 lines with the 'normal' ANSI syntax
    • an error with the predicates separate from the FROM clause and predicate order t3 - t1, t3 - t2
    • a result of 15 lines with separated from the FROM clause predicates and predicate t3 - t2, t1 - t3 reverse order

    A look at the CBO (event 10053) trace we see for queries returning a result the following 'final request after transformations"(reformatted):

    / * the normal ANSI syntax * /.

    SELECT COUNT (*) 'COUNT (*).

    OF "C ##TEST". " T1""T1 ".

    "C ##TEST". " T3""T3 ".

    "C ##TEST". " T2""T2 ".

    WHERE "T3". ' ' ID ' = 'T2 '. "" IDENTITY CARD ".

    (AND "T3". ' ' ID ' = 'T1 '. "" IDENTITY CARD ".

    / * the strange ANSI syntax: predicate of order 2, 1 * /.

    SELECT COUNT (*) 'COUNT (*).

    OF "C ##TEST". " T1""T1 ".

    (SELECT "T3". ' ' 'ID' ID. '

    OF "C ##TEST". " T3""T3 ".

    "C ##TEST". " T2""T2 ".

    WHERE "T3". ' ' ID ' = 'T2 '. (' ' ID ') "from $_subquery$ _004.

    WHERE "from $_subquery$ _004. "ID"(+) = "T1". "" IDENTITY CARD ".

    So we see that the 'normal' ANSI version indeed remove the outer join, while the version of working with separate predicates is still an outer join - and I think that explains the different results of your initial query. Track also shows some 'ANSI architecture' (with a small I) information (since the ANSI syntax is internally converted into traditional Oracle join syntax) and the (Ouattara) on the elimination of the outer join (for the 'normal' ANSI query: "Ouattara: outer join of T3 and T1 to join inner conversion.") considered Ouattara: given the predicate "T3". ' ID '= 'T1'. » ID » »). The result of the architecture 'ANSI' is different in the two cases is not a surprise that the heuristic transformations finally also return different results.

    Basically, I think that the question is indeed the order of operations:

    • If inner join t2 t3 and then the outer join T1 with the resulting 10 lines of the first step we get 15 ranks accordingly (since t1 contains 15 lines)
    • If we join outer t1 to t3 (15 lines) and then do the inner join T2 on t3.id (i.e. NON NULL only for 10 T3 lines) we get only 10 lines in the final result

    Personally, I would try to separate these operations in subqueries (as in the final transformation for the query "strange ANSI syntax: predicate of order 2, 1") to make sure that I still understand the logic of my combinations.

  • Update with INNER JOIN

    Hello

    My update with the inner join does not seem to work.

    UPDATE RECAP R SET R.FLAVOR = (SELECT FN. FLAVOR_NDC FN FLAVOR, REPLACE CAP R WHERE R.NDC11 = FN. NDC11)

    When I write the query above, the inner circle question (SELECT FN. FLAVOR_NDC FN FLAVOR, REPLACE CAP R WHERE R.NDC11 = FN. NDC11) returns multiple lines, and it's a new syntax for me (as I was Teradata and SQL server).

    Can you please how this request can be written to make it work?

    I get the error message below

    SQL error: ORA-01427: einreihig subquery returns multiple rows
    01427 00000 - "einreihig subquery returns several lines.

    1. fix your code:

    UPDATE RECAP R SET R.FLAVOR = (SELECT FN.FLAVOR FROM FLAVOR_NDC FN WHERE R.NDC11 = FN.NDC11)
    

    2. you can use the fusion

    merge into RECAP R
    using FLAVOR_NDC FN
    on(R.NDC11 = FN.NDC11)
    when matched then
         update
         set R.FLAVOR = FN.FLAVOR
    

    Kind regards
    Malakshinov Sayan

  • Urgent help please.  Inner join caused the error ora-00933

    I ran it, works great:
    SELECT DIFFERENT EXP. EXP_ID,
    EXP. DATU_EXP_WIRE_CENTER_CLLI,
    EXP. DATU_EXP_IP,
    EXP. DATU_EXP_CLLI,
    EXP. DATU_EXP_PORT,
    EXP. DATU_EXP_NAME,
    EXP. DATU_EXP_CITY,
    EXP. DATU_EXP_STATE,
    EXP. DATU_EXP_SW_VERSION,
    DECODE (LAST_ALARM. LAST_ALARM_DATE, NULL, TO_CHAR (SYSDATE, ' YYYY/MM/DD HH24:MI:SS'),
    TO_CHAR (LAST_ALARM. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS STATUS_DATE,
    DECODE (LAST_ALARM. ALARM_NAME, NULL, "disconnected", LAST_ALARM. ALARM_NAME) AS DATU_STATUS,
    DECODE (LAST_ALARM. ALARM_CLASS, NULL, 'OTHER', LAST_ALARM. ALARM_CLASS) AS IS_ERROR_STATUS,

    DECODE (LAST_RESOURCE. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_RESOURCE. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS RESOURCE_STATUS_DATE,
    DECODE (LAST_RESOURCE. RESOURCE_CODE_NAME, NULL, ", LAST_RESOURCE. RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
    DECODE (LAST_RESOURCE. RESOURCE_CODE_CLASS, NULL, ", LAST_RESOURCE. RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
    DECODE (LAST_OPER. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_OPER. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS OPER_STATUS_DATE,
    DECODE (LAST_OPER. OPER_CODE_NAME, NULL, ", LAST_OPER. OPER_CODE_NAME) AS OPER_STATUS,
    DECODE (LAST_OPER. OPER_CODE_CLASS, NULL, ", LAST_OPER. OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,

    EXP BEGIN_MAINT_WINDOW, RTU. RTU_NAME
    OF TT_DATU_EXP_UNIT_INFO EXP
    left outer join
    (SELECT distinct alarmed_datus. EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS and alarmed_datus. LAST_ALARM_DATE
    Of alarmed_datus (SELECT EXP_ID, MAX (ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID)
    inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus. EXP_ID AND b.ALARM_TIME = alarmed_datus. LAST_ALARM_DATE
    inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE
    ) LAST_ALARM on EXP.. EXP_ID = LAST_ALARM. EXP_ID
    left outer join
    (SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
    FROM (SELECT EXP_ID, MAX (RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
    OF TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID) a
    inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
    inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE
    ) LAST_RESOURCE on EXP.. EXP_ID = LAST_RESOURCE. EXP_ID
    left outer join
    (SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
    FROM (SELECT EXP_ID, MAX (OPER_CODE_TIME) AS LAST_ALARM_DATE
    OF TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID) a
    inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
    inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE) LAST_OPER on EXP.. EXP_ID = LAST_OPER. EXP_ID
    inner join TT_DATU_LRN_MAP on exp. EXP_ID = NAB NAB. EXP_ID AND TRIM (NAB. LRN) AS p_LRN
    inner join TT_RTU_TYPES on exp. RTU_TYPE_ID = RTU RTU. RTU_TYPE_ID
    WHERE THERE IS NOT (SOME SATELLITE_EXP_ID OF TT_HOST_SATELLITE WHERE EXP. EXP_ID = SATELLITE_EXP_ID)
    AND EXP.IS_PRIMARY_ADDRESS LIKE p_isPrimary;
    ON THE OTHER
    OPEN FOR V_cursor
    SELECT EXP. EXP_ID,
    EXP. DATU_EXP_WIRE_CENTER_CLLI,
    EXP. DATU_EXP_IP,
    EXP. DATU_EXP_CLLI,
    EXP. DATU_EXP_PORT,
    EXP. DATU_EXP_NAME,
    EXP. DATU_EXP_CITY,
    EXP. DATU_EXP_STATE,
    EXP. DATU_EXP_SW_VERSION,
    DECODE (LAST_ALARM. LAST_ALARM_DATE, NULL, TO_CHAR (SYSDATE, ' YYYY/MM/DD HH24:MI:SS'), TO_CHAR (LAST_ALARM. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS STATUS_DATE,
    DECODE (LAST_ALARM. ALARM_NAME, NULL, "disconnected", LAST_ALARM. ALARM_NAME) AS DATU_STATUS,
    DECODE (LAST_ALARM. ALARM_CLASS, NULL, 'OTHER', LAST_ALARM. ALARM_CLASS) AS IS_ERROR_STATUS,

    DECODE (LAST_RESOURCE. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_RESOURCE. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS RESOURCE_STATUS_DATE,
    DECODE (LAST_RESOURCE. RESOURCE_CODE_NAME, NULL, ", LAST_RESOURCE. RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
    DECODE (LAST_RESOURCE. RESOURCE_CODE_CLASS, NULL, ", LAST_RESOURCE. RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
    DECODE (LAST_OPER. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_OPER. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS OPER_STATUS_DATE,
    DECODE (LAST_OPER. OPER_CODE_NAME, NULL, ", LAST_OPER. OPER_CODE_NAME) AS OPER_STATUS,
    DECODE (LAST_OPER. OPER_CODE_CLASS, NULL, ", LAST_OPER. OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,

    EXP BEGIN_MAINT_WINDOW, RTU. RTU_NAME
    OF TT_DATU_EXP_UNIT_INFO EXP
    (in left outer join
    SELECT distinct alarmed_datus. EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS and alarmed_datus. LAST_ALARM_DATE
    Of alarmed_datus (SELECT EXP_ID, MAX (ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID)
    inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus. EXP_ID AND b.ALARM_TIME = alarmed_datus. LAST_ALARM_DATE
    inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE)
    LAST_ALARM on EXP.. EXP_ID = LAST_ALARM. EXP_ID
    left outer join
    (SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
    FROM (SELECT EXP_ID, MAX (RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
    OF TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID) a
    inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
    inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE) LAST_RESOURCE on EXP.. EXP_ID = LAST_RESOURCE. EXP_ID
    left outer join
    (SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
    FROM (SELECT EXP_ID, MAX (OPER_CODE_TIME) AS LAST_ALARM_DATE
    OF TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID) a
    inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
    inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
    ) LAST_OPER on EXP.. EXP_ID = LAST_OPER. EXP_ID ORDER BY EXP. DATU_EXP_CLLI
    inner join TT_RTU_TYPES on exp. RTU_TYPE_ID = RTU RTU. RTU_TYPE_ID
    WHERE THERE is NOT (SOME SATELLITE_EXP_ID OF TT_HOST_SATELLITE WHERE EXP.. EXP_ID = SATELLITE_EXP_ID) AND EXP.IS_PRIMARY_ADDRESS love
    p_isPrimary;


    However this one:

    SELECT EXP. EXP_ID,
    EXP. DATU_EXP_WIRE_CENTER_CLLI,
    EXP. DATU_EXP_IP,
    EXP. DATU_EXP_CLLI,
    EXP. DATU_EXP_PORT,
    EXP. DATU_EXP_NAME,
    EXP. DATU_EXP_CITY,
    EXP. DATU_EXP_STATE,
    EXP. DATU_EXP_SW_VERSION,
    DECODE (LAST_ALARM. LAST_ALARM_DATE, NULL, TO_CHAR (SYSDATE, ' YYYY/MM/DD HH24:MI:SS'),
    TO_CHAR (LAST_ALARM. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS STATUS_DATE,
    DECODE (LAST_ALARM. ALARM_NAME, NULL, "disconnected", LAST_ALARM. ALARM_NAME) AS DATU_STATUS,
    DECODE (LAST_ALARM. ALARM_CLASS, NULL, 'OTHER', LAST_ALARM. ALARM_CLASS) AS IS_ERROR_STATUS,


    DECODE (LAST_RESOURCE. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_RESOURCE. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS RESOURCE_STATUS_DATE,
    DECODE (LAST_RESOURCE. RESOURCE_CODE_NAME, NULL, ", LAST_RESOURCE. RESOURCE_CODE_NAME) AS RESOURCE_STATUS,
    DECODE (LAST_RESOURCE. RESOURCE_CODE_CLASS, NULL, ", LAST_RESOURCE. RESOURCE_CODE_CLASS) AS IS_RESOURCE_ERROR_STATUS,
    DECODE (LAST_OPER. LAST_ALARM_DATE, NULL, ", TO_CHAR (LAST_OPER. LAST_ALARM_DATE, "YYYY/MM/DD HH24:MI:SS")) AS OPER_STATUS_DATE,
    DECODE (LAST_OPER. OPER_CODE_NAME, NULL, ", LAST_OPER. OPER_CODE_NAME) AS OPER_STATUS,
    DECODE (LAST_OPER. OPER_CODE_CLASS, NULL, ", LAST_OPER. OPER_CODE_CLASS) AS IS_OPER_ERROR_STATUS,


    EXP BEGIN_MAINT_WINDOW, RTU. RTU_NAME
    OF TT_DATU_EXP_UNIT_INFO EXP
    left outer join
    (
    SELECT distinct alarmed_datus. EXP_ID, c.ALARM_NAME, c.ALARM_TYPE, c.ALARM_CLASS and alarmed_datus. LAST_ALARM_DATE
    Of alarmed_datus (SELECT EXP_ID, MAX (ALARM_TIME) AS LAST_ALARM_DATE FROM TT_DATU_EXP_ALARM_INFO GROUP BY EXP_ID)
    inner join TT_DATU_EXP_ALARM_INFO b on b.EXP_ID = alarmed_datus. EXP_ID AND b.ALARM_TIME = alarmed_datus. LAST_ALARM_DATE
    inner join TT_DATU_EXP_ALARM_TYPES c on b.ALARM_TYPE = c.ALARM_TYPE) LAST_ALARM on EXP.. EXP_ID = LAST_ALARM. EXP_ID

    left outer join
    (SELECT distinct a.EXP_ID, c.RESOURCE_CODE_NAME, c.RESOURCE_CODE_TYPE, c.RESOURCE_CODE_CLASS, a.LAST_ALARM_DATE
    FROM (SELECT EXP_ID, MAX (RESOURCE_CODE_TIME) AS LAST_ALARM_DATE
    OF TT_DATU_EXP_RESOURCE_CODE_INFO GROUP BY EXP_ID) a
    inner join TT_DATU_EXP_RESOURCE_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.RESOURCE_CODE_TIME = a.LAST_ALARM_DATE
    inner join TT_DATU_EXP_RESOURCECODE_TYPES c on b.RESOURCE_CODE_TYPE = c.RESOURCE_CODE_TYPE) LAST_RESOURCE on EXP.. EXP_ID = LAST_RESOURCE. EXP_ID
    left outer join
    (SELECT distinct a.EXP_ID, c.OPER_CODE_NAME, c.OPER_CODE_TYPE, c.OPER_CODE_CLASS, a.LAST_ALARM_DATE
    FROM (SELECT EXP_ID, MAX (OPER_CODE_TIME) AS LAST_ALARM_DATE
    OF TT_DATU_EXP_OPER_CODE_INFO GROUP BY EXP_ID) a
    inner join TT_DATU_EXP_OPER_CODE_INFO b on b.EXP_ID = a.EXP_ID AND b.OPER_CODE_TIME = a.LAST_ALARM_DATE
    inner join TT_DATU_EXP_OPER_CODE_TYPES c on b.OPER_CODE_TYPE = c.OPER_CODE_TYPE
    ) LAST_OPER on EXP.. EXP_ID = LAST_OPER. EXP_ID ORDER BY EXP. DATU_EXP_CLLI
    inner join TT_RTU_TYPES on exp. RTU_TYPE_ID = RTU RTU. RTU_TYPE_ID
    WHERE the EXP.IS_PRIMARY_ADDRESS as p_isPrimary;

    It does not work kept send me errors:
    [ORA-00933: SQL not correctly completed command]


    Any guru can help? I need to have this resolved effect today.
    Thanks in advance.
  • Help of query SQL - inner joins and the separate results

    Hello

    ASP VB, SQL Server

    I have a structure of data base with 3 tables - users, albums and photos. each user has a identifier unique, each record has a unique albumid and also contains a column with the user name. each record in the photo has a unique id so that store the user name and the album in which the image belongs.

    I'm writing a query that returns a list of the albums for a particular user (based on a user name query string) and who will also bring back the id of the first record in the table for each of these albums photo.

    the closest I get is to run a query to select albumid albums where userid = varuserid with a join internal on the pictures table to remove the photo ID - problem I then it comes out all the photos from the photos table where userid = varuserid, so when I do a repeat region to display a list of albums for a certain user It produces a list of all the photos where userid = varuserid

    I really want to return just a list of ID album based on the username variable, but also to return the first record in the table of photos for each of these albumids

    I tried different combinations of inner joins, select distinct etc but no joy.

    any suggestion would be appreciated as am floundering here...




    First, you must define 'first' with regard to the photos. Is there a
    timestamp? They are numbered inside the album? Do you really care who is
    "first", or do you want simply a shot? You also neglected to indicate if they are
    empty photo albums have been allowed. I assumed that the empty albums are not
    allowed.

    Whatever you decide, the answer will be similar.
    SQL Server tends to get better results with joins with subqueries. You will have
    See such a written request more often with subqueries, and there isn't
    nothing wrong with that, but I'll use a join on a derived table. I have
    have not all column names (hint, hint), so I made them, but the
    Comments should help out you.

    SELECT A.Title, P.PhotoID, P.Caption, A.AlbumID, P.ImagePath
    FROM dbo. A albums
    -build a table derived, consisting of photo ID lowest for each
    album.
    INNER JOIN (SELECT AlbumID, MIN (PhotoID) AS FirstPhoto FROM dbo. Photos
    AlbumID GROUP) AS PM WE A.AlbumID = PM. AlbumID
    -details of the photo for the photo shown in the table above
    INNER JOIN dbo. Photos P on A.AlbumID = P.AlbumID AND
    H. FirstPhoto = P.PhotoID
    User A.UserID ='some WHERE '

    "tedstar" wrote in message
    News:ee4pfn$de$1@forums. Macromedia.com...
    > I am writing a query that returns a list of the albums for a
    > particular user (based on a user name query string) and also bring
    > return
    > the id of the first record in the table for each of these albums photo.

  • Need help with the ANSI Join syntax

    Version: 11.1.0.7

    I have my select statement that returns 3000 lines and looks like
    select ..
    from tab1 a,tab2 b,tab3 c
    where a.c1=b.c1 and
    b.c2 = c.c2(+)
    and ...
    group by
    ..
    I want to convert it to ANSI SQL, because it must be able to Hibernate, and the developer says that Hibernate include only ANSI SQL. I tried something like
    select ..
    from tab1 a INNER JOIN tab2 b
    ON a.c1=b.c1 
    LEFT OUTER JOIN tab3 c
    ON b.c2=c.c2
    where ...
    group by
    ..
    I felt bad and it turned out to be the same. It returns no rows. Please help with the correct syntax.

    I'm not sure, sorry, because it's certainly the ANSI equivalent to the non-ANSI.

    Would you have examples of queries and data that you can reproduce the problem with, and that we could analyze?

    Published by: Seanmacgc on July 15, 2009 12:48

    If there is no Clause WHERE conditions in the original that are included in the ANSI version of the query in the WHERE Clause for the EXTERNAL table itself joined, then that could transform the JOIN JOIN internally, that is, all the filters on the EXTERNAL joined table should be included in the JOIN predicate - IT (b.c2 = c.2 AND c.c3 = 'X').

  • help the procedure...

    Hello world

    I created the following procedure to create a table and insert with select data, the procedure being executed very well but when I write a query using the table "mrsa_admit_date", and then he throws me an error with "table or view does not exist.

    Lost something here?

    With the help of oracle 11g

    create or replace PROCEDURE P_MRSA_STEP3 AS

    BEGIN

    run immediately 'truncate table mrsa_admit_date;

    insert into mrsa_admit_date

    Select A.pat_id, A.pat_enc_csn_id, P.hsp_account_id, min (A.effective_time) in the Admit_date

    of clarity_adt@clarprod A

    inner join mrsa_cms_units mcu

    On mcu.dept_id = A.department_id

    Join hsp_account@clarprod P internal

    On A.pat_enc_csn_id = P.prim_enc_csn_id

    -where

    -P.hsp_account_id = 12226392031

    -In (10610792118,41567152070)

    A.pat_id, A.pat_enc_csn_id, P.hsp_account_id group

    commit;

    END P_MRSA_STEP3;

    Thank you.

    Well it is because you have no code to create a table. You have a truncation, and then an insert.

  • Issue of inner joins

    Hi all
    I have a few tables with samples as:
    CREATE OR REPLACE TABLE hotel
    ( 
         hotel_id             int  NOT NULL ,
         hotel_name           varchar2(50)  NULL ,
         hotel_address        varchar2(100)  NULL
    );
    
    CREATE OR REPLACE TABLE people_type
    ( 
         people_type_id       int  NOT NULL ,
         type_des             varchar2(30)  NOT NULL
    );
    
    CREATE OR REPLACE TABLE hotel_people
    ( 
         hotel_id                int  NOT NULL ,
         people_type_id      int  NOT NULL ,
         age_min                int  NULL ,
         age_max               int  NULL
    );
    
    CREATE OR REPLACE TABLE hotel_service
    ( 
         hotel_id              int  NOT NULL ,
         qty_room             int  NOT NULL ,
         qty_people           int  NOT NULL,
         qty_people_extra      int  NOT NULL
    );
    
    insert into hotel(hotel_id, hotel_name, hotel_address)
    values(1,'hotel1','hotel1 address1');
    insert into hotel(hotel_id, hotel_name, hotel_address)
    values(2,'hotel2','hotel2 address2');
    insert into hotel(hotel_id, hotel_name, hotel_address)
    values(3,'hotel3','hotel3 address3');
    insert into hotel(hotel_id, hotel_name, hotel_address)
    values(4,'hotel4','hotel4 address4');
    
    insert into people_type (people_type_id, type_des)
    values (1,'Baby');
    insert into people_type (people_type_id, type_des)
    values (2,'Young');
    insert into people_type (people_type_id, type_des)
    values (3,'Adult');
    
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (1,1,0,2);
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (1,2,3,10);
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (1,3,11,200);
    
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (2,2,3,17);
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (2,3,18,200);
    
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (3,3,18,200);
    
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (4,1,0,2);
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (4,2,3,10);
    insert into hotel_people (hotel_id, people_type_id, age_min, age_max)
    values (4,3,11,200);
    
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (1,10,2,1);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (1,5,4,0);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (2,6,2,1);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (2,12,3,1);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (3,10,2,1);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (3,5,4,0);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (4,6,2,1);
    insert into hotel_service (hotel_id, qty_room, qty_people,qty_people_extra)
    values (4,12,3,1);
    As you can see I have Hotels with basic information, persons of type hotel_people (1:baby, 2:young and 3:Adult), which contains the type of people that each hotel can accommodate with min max age and hotel_service that contains the info from the number of rooms and the amount of people that can be in each room.
    I'm trying to get the records that match my condition as:
    1. I want to get the hotels that can accommodate 4 pieces with adults of 3 for each room.
    2 get hotels that can accommodate 6 rooms 2 where 2 of the bedrooms can have 1 young (3 people per room) and young people 9 years.

    For 1:
    select h.hotel_id, h.hotel_name, ss.qty_room, t.type_des, ss.qty_people, p.age_min, p.age_max
    from hotel h
    inner join hotel_service ss on h.hotel_id = ss.hotel_id
    inner join hotel_people p on h.hotel_id = p.hotel_id
    inner join people_type t on p.people_type_id = t.people_type_id
    where ss.qty_room >= 4
    and t.people_type_id = 3
    and ss.qty_people >= 3
    For 2:
    select h.hotel_id, h.hotel_name, ss.qty_room, t.type_des, ss.qty_people, p.age_min, p.age_max
    from hotel h
    inner join hotel_service ss on h.hotel_id = ss.hotel_id
    inner join hotel_people p on h.hotel_id = p.hotel_id
    inner join people_type t on p.people_type_id = t.people_type_id
    where ss.qty_room >= 6
    and ss.qty_people >= 3
    and t.people_type_id in (2,3)
    and 9 between p.age_min and p.age_max
    This does not work, the start of the query becomes more complex if I try to search for multiple rooms with a different number of people and children of different ages.
    Can anyone help with this?
    Thank you

    Published by: user9542267 on April 3, 2012 22:26

    Hello

    user9542267 wrote:
    ... Yes, what I need is a hotel that can accommodate TWO adults and youth. What do you mean by two copies?

    Right now I read something on the Grand Duke by Gilbert. I also have a book with the complete works of Gilbert, so I can leave it open, and when I see a reference in the commentary, I see exactly what the author is talking about in the book. However, when the comment compares some parts of this game to the other plays of Gilbert, The Yeomen of the Guard , it gets hard, because I have to keep changing the pages in the complete works, and I can't see both at the same time. It would be much easier if I could get a full second copy of the work; then I could leave a copy of the Grand Duke and leave the other copy open to The Yeomen of the Guard . This is similar to what you should do with the table of hotel_people, and what I do with the table scott.emp below.

    Imagine (using tables in the scott schema) you have to find the departments where both an analyst and a clerk to work.
    This:

    SELECT DISTINCT
              d.*
    FROM       scott.dept     d
    JOIN       scott.emp     e  ON     d.deptno     = e.deptno
    WHERE       job          IN ('ANALYST', 'CLERK')
    ORDER BY  d.deptno
    ;
    

    product

    DEPTNO DNAME          LOC
    ------ -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
    

    because all these departments have either an analyst or a clerk. However, only deptno = 20 a time .
    If, instead of a single table of big job, you have a separate table for each Olympic Games, then you might do something like this:

    SELECT DISTINCT
              d.*
    FROM       scott.dept     d
    JOIN       analyst     a  ON     d.deptno     = a.deptno
    JOIN       clerk          c  ON     d.deptno     = c.deptno
    ORDER BY  d.deptno
    ;
    

    Of course, you don't have tables separated like that, but you could generate result sets who behaved as separte tables, for example:

    WITH     analyst          AS
    (
         SELECT  *
         FROM     scott.emp
         WHERE     job     = 'ANALYST'
    )
    ,     clerk          AS
    (
         SELECT  *
         FROM     scott.emp
         WHERE     job     = 'CLERK'
    )
    SELECT DISTINCT
              d.*
    FROM       scott.dept     d
    JOIN       analyst     a  ON     d.deptno     = a.deptno
    JOIN       clerk          c  ON     d.deptno     = c.deptno
    ORDER BY  d.deptno
    ;
    

    Note that the main request is exactly what I posted earlier.
    What produces the right output:

    DEPTNO DNAME          LOC
    ------ -------------- -------------
        20 RESEARCH       DALLAS
    

    There is no need to actually generate separate result sets, however. You can use two copies of the table scott.emp in the same query, as follows:

    SELECT DISTINCT
              d.*
    FROM       scott.dept     d
    JOIN       scott.emp     a  ON     d.deptno     = a.deptno
    JOIN       scott.emp     c  ON     d.deptno     = c.deptno
    WHERE       a.job          = 'ANALYST'
    AND       c.job          = 'CLERK'
    ORDER BY  d.deptno
    ;
    
  • Helps the complex expression to Group By

    Hi all
    I use a BPM opensource to store variables in a Workflow process. Variables are stored in an Oracle 10 database and can be retrieved using the native Api of BPM (Java) or by using Sql. For performance reasons, I use simple SQL to collect a list filtered workflow variables.

    Here is a simplified version of the BPM_INSTANCE Table:

    [NAME] [VALUE] [PROCESS_INSTANCE]
    =====================================
    AREA IN ADDITION TO 1 125
    ACME CUSTOMER 125
    ID_WO 500 125

    2 200 FIELD
    200 TEST CLIENT
    ID_WO 501 200

    1 225 FIELD
    CUSTOMER MODEL 225
    ID_WO 502 225

    Each PROCESS_INSTANCE has a set of variables that have a NAME and a VALUE.

    My need is to collect the list of all (500,501,502) ID_WO, PROCESS_INSTANCE belongs to a DOMAIN (ex. 1) and one client (e.g. ACME)

    I started coding the SQL:

    Select VALUE from BPM_INSTANCE where NAME = 'ID_WO' and PROCESS_INSTANCE in
    (select PROCESS_INSTANCE from BPM_INSTANCE, whose NAME = "CUSTOMER" and VALUE = "ACME"
    )
    However, I am not able to meet several conditions (for example I need also the PROCESS_INSTANCE also contains an AREA = 1).
    Can someone help me?
    Thank you
    Frank

    Hello

    Would this work:

    with data as (
     select 'AREA' as name, '1' as value, '125' as pi from dual union all
     select 'CLIENT' , 'ACME', '125' from dual union all
     select 'ID_WO', '500', '125' from dual union all
     select 'AREA', '2', '200' from dual union all
     select 'CLIENT', 'TEST', '200' from dual union all
     select 'ID_WO', '501', '200' from dual union all
     select 'AREA', '1', '225' from dual union all
     select 'CLIENT', 'DUMMY', '225' from dual union all
     select 'ID_WO', '502', '225' from dual)
    select o.value, i.value, ii.value from data o
     inner join data i on ( o.pi = i.pi )
     inner join data ii on ( o.pi = ii.pi ) where o.name = 'ID_WO' and i.name = 'AREA' and ii.name = 'CLIENT'; 
    

    HtH
    Johan

  • problem with a query, inner join

    Hello;

    I am trying innerjoin these 2 tables in my request for a page that will allow you to add / modify records. Right now, it tells me that I have a lag of data. I do not see where I was wrong. Can someone help me?


    This is my code:

    < name cfparam = "url. CategoryID"type ="integer"default ="0">
    < name cfparam = 'subID' type = 'integer' default = '#url. CategoryID #">"
    < name cfparam = "subName" default = "" >
    < name cfparam = "CategoryID" default = "" >
    < name cfparam = "Name" default = "" >

    < cfif url. CategoryID GT 0 >
    < name cfquery = "categRec" dataSource = "#APPLICATION.dataSource #" >
    SELECT merchSubCat.subName, merchSubCat.subID, categories. CategoryID, Categories.Name
    OF merchSubCat
    JOIN INTERNAL categories
    ON merchSubCat.CategoryID = categories. CategoryID
    WHERE merchSubCat.subID = < cfqueryparam value = '#url. "CategoryID #" cfsqltype = "cf_sql_integer" >
    < / cfquery >

    <!-if the records were found, store the values->
    < cfif categRec.RecordCount EQ 1 >
    < cfset CategoryID = categRec.subID >
    < cfset subName = categRec.subName >
    < cfset CategoryID = categRec.CategoryID >
    < cfset Name = categRec.Name >
    < / cfif >
    < / cfif >

    It's my mistake:

    Run database query error.

    [Macromedia] [SequeLink JDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Type in an expression mismatch.
    The error occurred in C:\Websites\187914kg3\admin\cms\merchant\merchSub-edit.cfm: line 16

    14 : INNER JOIN Categories
    15 :     ON merchSubCat.CategoryID = Categories.CategoryID
    16 : WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
    17 : </cfquery>
    18 : 
    

    I don't see what I did wrong, another pair of eyes can see where I missed something?

    Thank you

    I think that you just want to use the URL. CategoryID parameter:


    Ken Ford

  • SELECT - INNER JOIN / multi-table question

    I have a few pages where I can:
    register a new user
    Open as this user which brings me to a home page. from there I can go to 'my page' users where I can see their fine of the initial registry data. I have a link here where I can go to add to their additional profile data that I didn't want to bore in the original registration.

    It perfect all worked with the original test data, I've created in the database.

    After that I added the additional tables needed to feed the profile further I ran into trouble. I could create a new user, see in the database is fine. I see them on the homepage with their information through the Recordset. However when I'd go to their 'my page' none of their information would be fill and go to extra profile update page haven't fired a no records found message.

    Finally, I realized that the reason for this is because the SELECT statement is waiting for the other tables to fill. I filled in the missing data and the query to work. So... Now that I know what is causing the problem I need help to find a solution. Also, I'm still new to find work around me even after 4 days of research and reading messages.

    So when a new user registers, I need to be able to display data from the initial registration on the "my page" and get their user_id for profile tables add somehow so that when I go to the add profile page, there is a link.

    I don't know if I need to do something in the database or in my query. It there any sense to anyone? I need to create the user_id on other tables during registration of origin occurs? If so, how would I go all this?

    Thanks in advance. My INNER JOIN is attached in case it helps.

    I have a few pages where I can:
    register a new user
    Open as this user which brings me to a home page. from there I can go to 'my page' users where I can see their fine of the initial registry data. I have a link here where I can go to add to their additional profile data that I didn't want to bore in the original registration.

    It perfect all worked with the original test data, I've created in the database.

    After that I added the additional tables needed to feed the profile further I ran into trouble. I could create a new user, see in the database is fine. I see them on the homepage with their information through the Recordset. However when I'd go to their 'my page' none of their information would be fill and go to extra profile update page haven't fired a no records found message.

    Finally, I realized that the reason for this is because the SELECT statement is waiting for the other tables to fill. I filled in the missing data and the query to work. So... Now that I know what is causing the problem I need help to find a solution. Also, I'm still new to find work around me even after 4 days of research and reading messages.

    So when a new user registers, I need to be able to display data from the initial registration on the "my page" and get their user_id for profile tables add somehow so that when I go to the add profile page, there is a link.

    I don't know if I need to do something in the database or in my query. It there any sense to anyone? I need to create the user_id on other tables during registration of origin occurs? If so, how would I go all this?

    Thanks in advance. My INNER JOIN is attached in case it helps.

  • What are the inner workings of the grid in forms?

    Hi, I have some doubts, I want to know what are the inner workings of the grid in forms.

    1. how forms followed the value change in the grid?

    2. when we run the query that we will get the selected lines, then we changed some values in certain fields in the grid, how it follows the change in value? .how he knows the process is update or insert?

    It is this that my concept, when we realized the request forms will be store values in the tables with rowid.i thought a lot more, but I can't any idea on it.any help me?

    You just want to understand the functioning of the forms or you encounter some difficult techniques in certain areas?  If you have a hearing problem, please describe, and we can try to help.  If you try just to know how it all works, I would recommed referring to Forms Builder online help.

    In help, search for information on GET_RECORD_PROPERTY.  This part of the documentation provides a pretty good explanation as to what is happening and how to determine the current state of a folder.

    In short, when you make a change to a field that represents a recording of the db, a SELECT for UPDATE is issued.  This causes the recording to be blocked.  Actually change value, we monitor internally.  I won't go into the details on how we do here.

  • generator 10 I have a query with an inner join... join error unsupported expression! In a query, Report Designer cannot do a join?

    Hey in the 10 Report Builder Query Builder, I got an error:

    OftblFacility INNER JOIN tblStateProvince ON tblFacility.OIDStateProvince = tblStateProvince

    What is java.swl.SQLException: [Macromedia] [SequeLinkJDBC Driver] [ODBC Socket] [Microsoft] [ODBC Microsoft Access driver] Join expression not taken in charge.

    Why?

    Report Designer will automatically join tables only if you have defined a relationship between them in your database.

    In Report Designer, you can easily create a join by dragging a field from one table to the related field in the other table. It couldn't be simpler.

    See you soon

    Eddie

Maybe you are looking for