# Mysql joining tables

**URL:** <https://forum.kirupa.com/t/mysql-joining-tables/258029>\
**Category:** Uncategorized\
**Created:** [April 19, 2008, 9:26pm UTC](https://forum.kirupa.com/t/mysql-joining-tables/258029 "2008-04-19T21:26:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patch](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/patch/32/1095_2.png) [@Patch](https://forum.kirupa.com/u/Patch)\
**Post date:** [April 19, 2008, 9:26pm UTC](https://forum.kirupa.com/t/mysql-joining-tables/258029/1 "2008-04-19T21:26:17Z")

</div>

Hey, I need a little help joining two mysql tables. Basically in both tables i have a row named “bib\_id”. One table is named “bibs” the other “bib\_data”.

The table “bibs” contains the title of an item and “bib\_data” contains the data that goes under that item with the same bib\_id etc.

So what I need to do is get it so that I can echo the correct information from “bib\_data” under the correct title from “bibs”

so it would echo something like this:

TITLE1 FROM BIBS  
\*INFO1 FROM BIB\_DATA FOR TITLE1 FROM BIBS  
\*INFO2 FROM BIB\_DATA FOR TITLE1 FROM BIBS  
\*INFO4 FROM BIB\_DATA FOR TITLE1 FROM BIBS

TITLE2 FROM BIBS  
\*INFO3 FROM BIB\_DATA FOR TITLE2 FROM BIBS  
\*INFO5 FROM BIB\_DATA FOR TITLE2 FROM BIBS

etc… If that makes any sense?

I’ve been having ago, but I’ve had no luck

```php

$sql = "SELECT bibs.bib_id, bib_data.bib_id FROM bibs, bib_data WHERE bibs.bib_id = bib_data.bib_id";

```

What I have done above is more than likely waaay off the mark of what is suppose to be.

The row that contains the info “bib\_data” is also named bib\_data. Incase what I have done doesn’t make sense. I also need to filter the results by username/id in “bibs” I have a row named user etc…

If you have any advice, tips or tutorials that you know of, it would be a great help.

Thank you 🙂
