php - getting secondary name using sub query -


i have 2 tables, 1st table holds categories list , 2nd table holds profile information along 1st table category id foreign key. follow

table1

id  category  1    first    2    second 

table2

id  category name     phone 1    2       john    9999999999 

how retrieve table 2 records along category name (not id:2 shown in table 2)

i tried this,

select category, name, phone table2; 

i need see following line result

second, john, 9999999999 

get me out of step, in advance.

what need join, means "combine" 2 tables linking rows 1 table rows table based on criterion.

in case, criterion value of category in table2 must equal value of id in table1, expressed follows:

select table1.category,        table2.name,        table2.phone   table2 join   table1   on   table2.category = table1.id 

if needed, can add where clause limit result specific rows, e.g. where table1.id = 9999999999 filter rows have category 9999999999.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -