我试图从mysql数据库中提取一个字符。字符表有6列链接到项目表中的外来项目ID,我需要链接每个项目以获取项目ID,名称和外国图像ID,然后我需要将该foregin图像ID链接到我的图像表。并拉出图片网址。我在下面编码的代码是给我重复的图像网址。有谁知道它有什么问题吗?
这是我的结果。图片网址正在重复自己。我把project_users用来测试它,同样的事情发生了它现在没有被使用但将来会被使用。
我做了一个sqlfiddle,但看起来它的工作正确http://sqlfiddle.com/#!2/7896e/8
Array ( [name] => test1241 [0] => test1241 [gender] => [1] => [left_arm] => Images/Items/leftArm.png [2] =>
Images/Items/leftArm.png [legs] => Images/Items/legs.png [3] => Images/Items/legs.png [torso] =>
Images/Items/torso.png [4] => Images/Items/torso.png [head] => Images/Items/head.png [5] => Images/Items/head.png [hair] => Images/Items/hair.png [6] => Images/Items/hair.png [right_arm] => Images/Items/rightArm.png [7] => Images/Items/rightArm.png )
$sql = "SELECT
pc.project_characters_name as name,
pc.project_characters_gender as gender,
pia1.project_images_url as left_arm,
pia2.project_images_url as legs,
pia3.project_images_url as torso,
pia4.project_images_url as head,
pia5.project_images_url as hair,
pia6.project_images_url as right_arm
FROM project_characters AS pc
INNER JOIN project_users AS pu ON pc.fk_project_users_id = pu.project_users_id
INNER JOIN project_items AS pi1 ON pc.project_characters_left_arm = pi1.project_items_id
INNER JOIN project_items AS pi2 ON pc.project_characters_legs = pi2.project_items_id
INNER JOIN project_items AS pi3 ON pc.project_characters_torso = pi3.project_items_id
INNER JOIN project_items AS pi4 ON pc.project_characters_head = pi4.project_items_id
INNER JOIN project_items AS pi5 ON pc.project_characters_hair = pi5.project_items_id
INNER JOIN project_items AS pi6 ON pc.project_characters_right_arm = pi6.project_items_id
INNER JOIN project_images AS pia1 ON pi1.fk_project_images_id = pia1.project_images_id
INNER JOIN project_images AS pia2 ON pi2.fk_project_images_id = pia2.project_images_id
INNER JOIN project_images AS pia3 ON pi3.fk_project_images_id = pia3.project_images_id
INNER JOIN project_images AS pia4 ON pi4.fk_project_images_id = pia4.project_images_id
INNER JOIN project_images AS pia5 ON pi5.fk_project_images_id = pia5.project_images_id
INNER JOIN project_images AS pia6 ON pi6.fk_project_images_id = pia6.project_images_id
WHERE pc.project_characters_name=:name LIMIT 1";