Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate view or use innerjoins?
    primarykey
    data
    text
    <p>I have a normalized database, with foreign keys/primary keys giving one to many databases.</p> <p>I plan to access this database with PHP for the basic frontend/backend display. Now, my question comes from these two exampled queries: </p> <pre><code>CREATE VIEW `view` AS SELECT functiondetails.Detail, functionnames.ID, functionnames.FunctionName, functionnames.Catogory FROM functiondetails INNER JOIN functionnames ON functiondetails.AsscID = functionnames.ID </code></pre> <p>or</p> <pre><code>SELECT functiondetails.Detail, functionnames.ID, functionnames.FunctionName, functionnames.Catogory FROM functiondetails INNER JOIN functionnames ON functiondetails.AsscID = functionnames.ID </code></pre> <p>There is no error within the query as i've ran both without fail, but my overall question is this:</p> <p>if I plan to constantly reference alot of information from my database. Wouldn't it be easier to create a view, which will then update all the time with the newly added information, or would it be in better practice to have the second query on my actual php.. Example: </p> <pre><code>$Query = $MySQli-&gt;prepare(" SELECT functiondetails.Detail, functionnames.ID, functionnames.FunctionName, functionnames.Catogory FROM functiondetails INNER JOIN functionnames ON functiondetails.AsscID = functionnames.ID ") $Query-&gt;execute(); $Results = $Query-&gt;fetch_results(); $Array = $Results-&gt;fetch_array(MYSQLI_ASSOC); </code></pre> <p>Or to select from my view? </p> <pre><code>$Query = $MySQLi-&gt;prepare("SELECT * FROM `view`"); $Query-&gt;execute(); $Results = $Query-&gt;fetch_results(); $Array = $Results-&gt;fetch_array(MYSQLI_ASSOC); </code></pre> <p>So which one would be a better method to use for querying my database? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload