Jump to content

how to select multi tables


ctcp

Recommended Posts

You are going to need to define what you want to do more.

 

You could be doing this limitation in the PHP side of your application.

 

If you really want to do it in SQL you could probably do something like this:

 

SELECT *
FROM table2
WHERE ( SELECT credits FROM table1 ) > 0

 

~juddster

Link to comment
Share on other sites

table1

 

User  | credits |

user1  | 100    |

user2  | 0        |

 

table2

 

user  | links |

user1 | google.com |

user 2| xxx.com      |

 

 

how to query show link if user got credits

 

Im sorry for first post i don't explane right :(

 

Link to comment
Share on other sites

SELECT User, credits, links
FROM table1 t1
JOIN table2 t2 ON t1.User = t2.user
WHERE t1.credits > 0

 

~juddster

 

 

Column 'credits' in field list is ambiguous

 

Not according to the table definition you provided us.

 

Please do not skip small details when providing us information because it just makes the responses you get back not as useful as they can be.

 

SELECT t1.User, t1.credits, t2.links
FROM table1 t1
JOIN table2 t2 ON t1.User = t2.user
WHERE t1.credits > 0 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.