Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6886991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:49:45+00:00 2026-05-27T05:49:45+00:00

I’m getting error Not unique table/alias while trying to display data from MySQL database

  • 0

I’m getting error “Not unique table/alias” while trying to display data from MySQL database to table. Assume it has something to do with foreign keys.

Here is SQL for creating tables, afterwords inserting some values. SQL went fine, no problems occurred, but I added the code, since it all go hand-in-hand with getting table on screen.

CREATE TABLE city (
   id int not null primary key auto_increment,
   name varchar(30) not null
) type=innodb;

CREATE TABLE cinema (
   id int not null  primary key auto_increment,
   name varchar(50) not null,
   city int not null,
   foreign key(city) references city(id)
) type=innodb;

CREATE TABLE movie (
   id int not null primary key auto_increment,
   name varchar(30) not null
) type=innodb;

CREATE TABLE relationship (
   whattime time NOT NULL,
   whichdate date NOT NULL,
   movieid int not null,
   cinemaid int not null,
   primary key (cinemaid, movieid),
   foreign key(movieid) references movie(id),
   foreign key(cinemaid) references cinema(id)
) type=innodb;

INSERT INTO city (id, name) VALUES (1, 'Paris'), (2, 'Copenhagen'), (3, 'London'), (4, 'Lisbon') 
INSERT INTO movie (id, name) VALUES (1, 'The Church')
INSERT INTO cinema (id, name, city) VALUES (1, 'Pathé', 1), (2, 'Cinemaxx', 2), (3, 'Cineworld', 3), (4, 'ZON Lusomundo', 4)
INSERT INTO relationship (whattime, whichdate, movieid, cinemaid) VALUES ('21:00:00', '2011-12-27', 1, 1), ('19:30:00', '2011-12-28', 1, 2), ('20:00:00', '2011-12-27', 1, 3), ('21:00:00', '2012-01-02', 1, 4)

Here is php, which gives me Not unique table/alias: ‘cinema’ error. Any ideas why it’s so?

<?php
include "inc/mysql_con.php";
mysql_select_db($db) or die(mysql_error());

$query = "select city.name, cinema.name, movie.name, date, time from city, cinema, relationship, movie";
$query .= "where cinema.city = city.id";
$query .= "and cinemaid = cinema.id";
$query .= "and movieid = movie.name";
$query .= "order by date";
mysql_query($query) or die(mysql_error()); 

echo "<table id='premiere'>";
echo "<tr> <th>CITY</th> <th>CINEMA</th> <th>DATE</th> <th>TIME</th></tr>";
 while($result = mysql_fetch_array( $query )) {
    echo "<tr><td>"; 
    echo $result['city.name'];
    echo "</td><td>"; 
    echo $result['cinema.name'];
    echo "</td><td>";
    echo $result['date'];
    echo "</td><td>";
    echo $result['time'];
    echo "</td></tr>";
}
echo "</table>";    
?>

UPDATE:
Now I got sql query right, code below

SELECT city.name, cinema.name, whichdate, whattime
FROM city, cinema, relationship, movie
WHERE cinema.city = city.id
AND cinemaid = cinema.id
ORDER BY whichdate

It displays table fine in SQL, but not in PHP:

ERROR: Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in content.php on line 75
line 75: while($query = mysql_fetch_array( $result )) {

Help will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:49:46+00:00Added an answer on May 27, 2026 at 5:49 am

    It looks like your string concatenation misses spaces so the first two lines would give … cinema, relationship, moviewhere cinema.city = city.id. In that case sql reads twice cinema … Could it be as simple as this ? I would echo the query before sending it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.