Jump to content

Search the Community

Showing results for tags 'Joins'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 5 results

  1. Hello, my question is regarding the code below. I usually see double left joins which refer to the table1 for both LEFT JOINS (FROM cities/cities as tabl1), this one is referring to countries.code as table1 in the second LEFT JOIN which confuses me somewhat. Is the first or second LEFT JOIN excecuted first? Basically I'm asking which has priority and which table gets LEFT JOINed first. SELECT cities.name AS city, urbanarea_pop, countries.name AS country, indep_year, languages.name AS language, percent FROM cities LEFT JOIN countries ON cities.country_code = countries.code LEFT JOIN languages ON countries.code = languages.code ORDER BY city, language; SELECT cities.name AS city, urbanarea_pop, countries.name AS country, indep_year, languages.name AS language, percent from languages right join countries on languages.code = countries.code right join cities on countries.code = cities.country_code order by city, language;
  2. Hi, I am trying to join two tables that have similar fields, but in slightly different formats. I was previously using something along the lines of like '%*%' Then SUBSTRING(b.fieldname,CHARINDEX(b.fieldname,'*',1)+1,9) However the format has now changed and I am struggling to put something together. Table A BD8K1 23161*35*201904231110*QULN Table B 23161*35*1 However the number of characters in both could vary so cant use that. Table A BD8K1 242875*10*201904251015*NBB1 Table B 242875*10*113 Is there some code that could be written that's something like: A – From the space use the value up to and including the 2nd * (BD8K1 is at the beginning of every value in table A so could potentially use from character 7) B – Use the value up to and including the 2nd * Any help would be very much appreciated. Thanks James
  3. I have 2 tables, one named branch, and one named branches, each with two columns. Structure is: | branch | branches | |======================|==================================| | cid int(9) | bid tinyint(2) | bid tinyint(2) | branch_name varchar(25) | |-----------------+-----------------+-----------------+-----------------------------------| | 111111111 | 3 | 1 | U.S. Army | |-----------------+-----------------+-----------------+-----------------------------------| | 222222222 | 1 | 2 | U.S. Air Force | |-----------------+-----------------+-----------------+-----------------------------------| | 333333333 | 6 | 3 | U.S. Marine Corps | |-----------------+-----------------+-----------------+-----------------------------------| | 444444444 | 2 | 4 | U.S. Navy | |-----------------+-----------------+-----------------+-----------------------------------| | 555555555 | 4 | 5 | U.S. Coast Guard | |-----------------+-----------------+-----------------+-----------------------------------| | 666666666 | 5 | 6 | Merchant Marines | +----------------+-----------------+-----------------+-----------------------------------+ The branch table stores the branch(es) veterens served in: branch.cid: a client id number (unique--the one to match up with $var[a fictitious id]). branch.bid: the number to reference the individual branches listed in the branches table The branches table holds the name of the service and an id for each one. branches.bid: an id for branch_name branches.branch_name: Branches of the military This is for the purpose of editing an individual's profile. What I'm trying to do is produce the list of checkboxes using the database with bid as the value from the branches table which gives me a checkbox listing for everybranch which is followed by branch_name. Getting this far is no problem but when I try to add the checks to the boxes. I'm either getting only a checkbox for the ones from previous input or they're all checked or I'm getting a list a mile long. I could write the checkboxes out one by one but the format is used for other details of the profile and sometimes new listings(such as those in the branches column) are added via a different script(which is already working) and the person filling out the form has no way of controlling what is in . The script that has me spinning in circles is as follows: $var=222222222; //$var is a user input to match up against cid column in branch table $result223 = mysql_query ("SELECT branches.branch_name, branches.bid as branchid,branch.bid, branch.cid FROM branches INNER JOIN branch ON branches.bid = branch.bid where branch.cid=$var ") or die(mysql_error()); echo"<br><br><table border='2px'>"; while($row223 = mysql_fetch_array( $result223 )) { $x223=$row223['branch_name']; $x223a=$row223['branchid']; $x223b=$row223['cid']; $x223c=$row223['bid']; echo"<tr><td>"; echo"<input type='checkbox'name='branch[]'value='$x223a'";if($x223b==$var){echo"checked";}echo"> $x223"; } I used 'group by branchid' and it showed a box for each branch which is what I'm wanting but it only uses the amount of listings from branch as is in the branches table and there are many entries in the branch table and if the $var entry was past the first six entries it didn't appear as checked. I removed group by and replaced it with 'where branch.cid=$var' and it would only show one checkbox per entry using that number. What am I doing wrong and what can I do to fix this? I need to display all from the branches table checked accordingly to the branch table. It is for doing updates. Please let me know if anything needs explained. This is my first run with php and it has me stumped.
  4. I want to perform a join on three tables.Table 1: part_masterColumn: Item, Item_statusTable 2: Order_DetailsColumn: Item, order_num, order_typeTable 3: OrderColumn: order_num, order_typeHere is the cardinality:part_master <--> order_details (1..1)order <--> order_details (1..n)I want to perform a search on order table, to retrieve item_status from part_master. In other word, I want to see item_status, for an order, using order_num as a search criteria.I tries something like this, however, it throws a exception:select part_master.item_status from part_master where item = (select item from order_details where order_details.order_num = order.order_num)The error says, the second 'select' statement returns multiple results which is not correct..Help....!
  5. SqlBeginner


    I am a recent grad and have started my career working for an It department. I am on my second project and am having some issues figuring out how to do a task.Our IT department manages many medical facilities. As of right now each facility is tracking their trainings invidually and now my boss (head of IT) wants all facilities to start to have a centralized system in tracking trainings. We purchased train tracks which is a system that pretty much tracks trainings and we have the client server version with web accessability. We ultimately want the HRM database to communicate with the train track database so that it'll automatically put new hires and certain positions into specified trainings. I am a beginner in SQL so my question is what would be the best route to go about getting these two databases to communicate this. I've seen some information about linking and joins but I'm still not 100% sure which would be the best route.
  • Create New...