Jump to content


Photo

combining 2 fields in a single mysql select query


  • Please log in to reply
3 replies to this topic

#1 mrjameer

mrjameer
  • Members
  • PipPipPip
  • Advanced Member
  • 102 posts

Posted 28 September 2006 - 11:46 PM

hi,

i want to combine 2 fields in a single select query

fields. pageheader name
values. abcd <div id="d"></div>

i want to merge/combine the pageheader and name in a single select query so that it can retrieve the pageheader with some styles which i have stored in another table

thanks
mrjameer



#2 yonta

yonta
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 29 September 2006 - 12:57 AM

Shouldn't be too hard to search on this, but if both fields are in the same table just

'SELECT field_one, field_two FROM tablename '

if they're in two separate tables

'SELECT tablename_one.field_one, tablename_two.field_two FROM tablename_one, tablename_two '

and if they're somehow related use the WHERE clause

do it, do it right, do it right now

#3 thedarkwinter

thedarkwinter
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationLondon

Posted 29 September 2006 - 10:06 AM

not 100% sure what your going for but you can mess around with this and see if it helps:

SELECT CONCAT(tbl1.pageheader,' ',tbl2.name) FROM tbl1 JEFT JOIN tbl2 ON tbl1.pageid=table2.pageid WHERE tbl1.pageid=1;

CONCAT will join the strings to make 1 string...
LEFT JOIN to get match the rows in the tables??

hope thats not completely useless to you!


Remember - if you don't figure it out yourself, you'll probably forget it tomorrow :)

#4 mrjameer

mrjameer
  • Members
  • PipPipPip
  • Advanced Member
  • 102 posts

Posted 29 September 2006 - 08:24 PM

hi,

i want to store css styles(simple box) in one table and in another table divs as one field and content as another field.so that when i combine these two tables in a select query i can get a some text in that box.how to do it.your help will be appreciated.i had stored styles and divs and content but when i retrieve it the content(text) is displaying outside of styles.i want to display the text in box

thanks
mrjameer




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users