5 Replies - 362 Views - Last Post: 15 March 2011 - 01:31 PM

#1 kenny22  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 12-September 09

table join

Posted 13 March 2011 - 10:19 PM

Anyone help with what the reverse of this code would be, at the moment it takes an ID number and matches it to a name so it echos the name not the id number, i need to do this in reverse now so that the name entered is stored as the names id number

Example:
id1 team1
code at moment displays team1, i need to insert team1 in text box but enter the id for it in DB


SELECT GameDate,Details, hometeam.teamname AS hometeamname,
fixtures.homescore , awayteam.teamname AS awayteamname, 
fixtures.awayscore 
FROM fixtures INNER  JOIN teams AS hometeam ON hometeam.teamid = fixtures.hometeam
INNER  JOIN teams AS awayteam
 ON awayteam.teamid = fixtures.awayteam


Is This A Good Question/Topic? 1
  • +

Replies To: table join

#2 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: table join

Posted 14 March 2011 - 01:53 AM

Instead of textbox I would use a combobox with a RowSource that includes the team ID and team name. The combobox would display the team name but the ID would be the value of the combobox. Then just refer to the combobox to get the team ID of the selected/entered name.
Was This Post Helpful? 0
  • +
  • -

#3 kenny22  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 12-September 09

Re: table join

Posted 14 March 2011 - 04:14 PM

View PostJune7, on 14 March 2011 - 01:53 AM, said:

Instead of textbox I would use a combobox with a RowSource that includes the team ID and team name. The combobox would display the team name but the ID would be the value of the combobox. Then just refer to the combobox to get the team ID of the selected/entered name.



sorry mislead a little bit using a text field not a textbox, don't think you can use combobox in a html form.

really just need the to know how to take the value of the textfield match it with the value in database field, get the ID for that field and insrt it into another table.

Example;

value from textfield = team1, search table teams and find team1 get the ID and insert id into table called results


kenny
Was This Post Helpful? 0
  • +
  • -

#4 kenny22  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 12-September 09

Re: table join

Posted 15 March 2011 - 12:56 PM

been playing about with code and got to this stage but it updates all the records in table intead of the record i want updated so missing something but cant see what

UPDATE fixtures 
INNER JOIN  teams on fixtures.hometeam = teams.teamid SET  HomeScore=%s, AwayScore=%s WHERE HomeTeam=teams.teamid

Was This Post Helpful? 0
  • +
  • -

#5 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: table join

Posted 15 March 2011 - 01:22 PM

This is a web app? Code is in an HTML page? If this were in VB/VBA/VB.net would have to concatenate the value. Don't know about web app.

Can have a box with a drop list on HTML page but guess that really is not like a combobox with multiple fields.
Was This Post Helpful? 0
  • +
  • -

#6 kenny22  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 12-September 09

Re: table join

Posted 15 March 2011 - 01:31 PM

View PostJune7, on 15 March 2011 - 01:22 PM, said:

This is a web app? Code is in an HTML page? If this were in VB/VBA/VB.net would have to concatenate the value. Don't know about web app.

Can have a box with a drop list on HTML page but guess that really is not like a combobox with multiple fields.



just a html form that i need to match the actual teamname with its corresponding id number from table teams as teamnames are stored as an int in the fixtures table
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1