Working with linked tables

I’m currently working on a website project that requires separate websites (different language dependant domains) to share a common image database. Thus, to avoid having to upload and link in the images for each individual website, I’ve decided to use data queries that take advantage of linked tables. The only main criteria are to have a common unique ID in order for the queries to work properly and all tables residing in the same database (which requires that you are able to make cross domain queries).

In my case I’m defining a unique page reference number for each “product page”, which obviously is the same for each individual language specific website, and an equal reference number for each image or image group. An example of a query/join statement that could “grab” your images could look like:

SELECT imageDB.filename, imageDB.filepath,
FROM imageDB, websitePages
WHERE imageDB.ref_number = websitePages.ref_number;

If you for some reason get a syntax error you could rewrite the statement as follows according to the ANSI SQL-92 syntax specification:

SELECT imageDB.filename, imageDB.filepath,
FROM imageDB INNER JOIN websitePages
ON imageDB.ref_number = websitePages.ref_number;

Note! The image table is named imageDB and the website table is named websitePages

The result gives you the name and path for your image related to a specific page/product. Quite useful isn’t it!?

More simple tips and online tutorials can be found e.g. here.

About Author