Trying to do the right queries..

I have a blog source I'm working on that uses the following tables:
TABLE posts:
+---------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| date | int(11) | NO | | NULL | |
| title | varchar(80) | NO | | NULL | |
| author | int(11) | NO | | NULL | |
| content | longtext | NO | | NULL | |
+---------+------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
TABLE tags:
+-------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(20) | NO | | NULL | |
| nav | tinyint(1) | NO | | NULL | |
| icon | varchar(40) | YES | | NULL | |
+-------+------------------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
TABLE tagpost:
+--------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+-------+
| tagid | int(10) unsigned | NO | | NULL | |
| postid | int(10) unsigned | NO | | NULL | |
+--------+------------------+------+-----+---------+-------+
tags and posts are pretty obvious; tagpost will be filled with multiple duplicates for normalization, basically. The issue I'm having is figuring out which sort of query I need to display posts properly. I'll need to fetch information from posts, tags, and users (for usernames).
I'm not sure where I need to start with this.. I think maybe subqueries or joining is what I need but I can't figure it out for myself.. any help?
I can post some of the code I'm using, but it's sort of hackish PHP.
Edit: Here's a graphical representation of my problem: http://bb.xieke.com/files/mysql-tables.png
Last edited by xelados (2008-10-15 19:19:44)

e_tank wrote:select posts.id, posts.title, posts.author, \
users.name as username, \
tagpost.tagid, \
tags.name \
from posts inner join users on posts.author = users.id \
inner join tagpost on posts.id = tagpost.postid \
inner join tags on tagpost.tagid = tags.id;
Unless you require that all posts have at least one tag, you should replace the last two INNER JOINs (or at least the second-to-last one -- I'm not certain what would happen in that case) with LEFT OUTER JOINs; as it stands, posts with no tags would be excluded from the results. (I assume an author is required, in which case the first INNER JOIN shouldn't cause a problem.)
Edit: I just verified in MySQL that -- indeed -- both of the last two joins should be LEFT OUTER JOINs (or, equivalently, LEFT JOINs).
Last edited by ssjlegendx (2008-10-16 01:04:32)

Similar Messages

  • I accidentally clicked add to dictionary on a misspelled word when I was trying to click the right spelling for it. How can I undo that so it will catch the misspelled word?

    I accidentally clicked add to dictionary on a misspelled word when I was trying to click the right spelling for it. How can I undo that so it will catch the misspelled word?

    You need to edit a file in your profile folder, for details see [[using the spell checker]].

  • Trying to Find the Right Phone for Me

    Hello,
    I'm thinking of switching to a BlackBerry, and could use a bit of help finding the right phone for me. I've browsed through them, but so far haven't been able to find what I'm looking for (and I'm not able to find out which phones have UMA or not in the compare section).
    Provider isn't important, as I'm fine changing my service.
    I'm looking for a phone that is:
    * Both WiFi and UMA compatible
    * GPS compatible
    * Preferably with a Camera
    Thanks for the help!

    This link may be useful to you:
    http://na.blackberry.com/eng/ataglance/networks/#t​ab_ddetail_subtab_wifi
    corrected url
    Message Edited by DigitalFrog on 06-26-2008 11:33 AM
    posted by DigitalFrog
    WARNING: May contain traces of nuts.

  • I zoomed in and out of pages, trying to get the right view to take a screen shot for facebook, and now my email homepage is HUGE when every other screen looks normal.

    When I set the view to Zoom Font only, my email page looks normal, but facebook is off. I can't seem to get the settings back to where they were before I tried taking that screen shot. I have tried restarting the computer, but that doesn't help. Am I just screwed?

    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages

  • Trying to find the right camera

    I have a Kodak EasyShare Z740.  It has 5 megapixels and 10X optical zoom.  It's good outdoors if it's sunny, or indoors with decent lighting (and it takes very good sports/fast action photos).  Unfortunately, I can't seem to take photos if I'm outdoors at night.  If I have the "sports" setting on, the picture comes out dark, even if I have the flash on.  If I have the "night" setting on, the pictures tend to come out blurry.
    My parents were supposedly trying to look for a camera for me for Christmas, but they've given up, cuz the prices are higher than they're willing to spend (my family has a tight budget this year, as do a lot of people).  I don't know how much my parents really bothered to look at cameras and whether or not they bothered to ask for a salesman's opinion.
    I just explained to my parents that I've been getting extremely frustrated because I go to a lot outdoor sporting events (i.e. baseball games) where I take pictures, but once the sun starts setting and the stadium lights turn on, I can't seem to take good pictures.  Yet I see pictures that people upload, so it feels like I'm alone.  My parents seem to think this is nothing and my camera is fine, but they barely know how to use their camera.
    I assume I really need a camera with more than 5 megapixels.  Anyone know of any make/models that won't break the bank?

    Hi fowkeska,
    Your described shooting condition of sports photography at night and outdoors is one of the most challenging photographic situations, and would be a challenge no matter what camera you have. The challenge really lies with availability of light. Even thought the human eye might see a scene as illuminated adequately at night, a camera does not. To capture an image at night using the available light you will need to set your camera's ISO to 800, which can only be done when the picture quality is set to good. Even at ISO 800 your pictures might turn out blurry, which usually means the camera is setting the shutter speed too slow. You could think about using the flash, but according to your manual when you are shooting a wide-angle shot the flash will only reach to 16 feet at ISO 168, and to 12 feet when set to telephoto. If you’re on a budget there is really is not camera that would do any better than what you have. More megapixels will not make an image that is incorrectly exposed look any better, but if an image is correctly exposed it will have better resolution if the camera has more megapixels. For this photographic situation I would look into getting a DSLR, which should allow you to set much higher ISO settings and allow you to use a much more powerful flash. I hope this helps!
    Thanks for posting,
    Allan
    Community Connector
    Best Buy® Corporate
    Allan|Senior Social Media Specialist | Best Buy® Corporate
     Private Message

  • Trying to Find the right KVM For my 3 Sunfire v250's

    Hello All,
    I currently have 3 SunFire v250 systems running Solaris 9/04. I tried using a Belkin PRO2 series KVM with USB ports. When rebooting the systems, I would get USB Timeout Errors, and some if not most of the time the system would not come up. I would need to go into the ALOM to reset each system usually several times before they would actually come up. The documentation for the KVM suggests booting the System up with the KB/Mouse/Monitor directly connected, and once the system is up then adding the KVM in the mix. This works, however when I reboot the system I am back to square one.
    I am looking for suggestions for a KVM switch (if there is one) that will work well with SunFire v250's. Also, I am using xvr-100 graphics cards in each system.
    Thank you in advance,
    -Chris

    Hello Chris,
    in the past there have been numerous posts on this topic (search for KVM).
    Unfortunately there is no easy answer, except that most people would recommend to use a terminal server/console server instead.
    Is your KVM listed on the following site or does Belkin recommend this KVM for Sun <b>SPARC</b> systems ?
    <b>I/O TECHNOLOGIES AND SOLUTIONS</b>
    Michael

  • Do i have the right equipment for CCNA-Wireless?

    Hello community i am Adan Ramirez, an aspiring Cisco Tech, and I'm trying to get the right equipment for the ccna wireless.
    Here is my shopping list:
    1. 2 Cisco LWAP 1252
    3. NME-WLC6-K9 module card
    Here is what i already have at home:
    1. 1841(2x) - iOS 12.4(24)
    2. 2811(2x) - iOS 15.something something...
    3. 3560 - iOS 15.something something
    4. 2960 - iOS 15.something something 
    Problem:  I don't know if the NME needs the latest iOS, the one i saw on eBay says it's version 4.2 something something.  I don't have three thousand dollars to buy a brand new module with iOS 7.0 or $ 12,000 to buy a 5500 WLC.  I'm a broke college student T_T, help!
    and thanks!

    Hi,
    This is sufficient for your CCNA wireless studies. Probably I would add a VM which can run WCS.
    If you really need a WLC, you can buy 4400 series controller (can run upto 7.0.x) for ~200-300 USD. This is the version tested in CCIEv2.0 lab exam as well.
    This is the Cisco forum you should follow for this CCNA-Wireless studies
    https://learningnetwork.cisco.com/groups/ccna-wireless-study-group
    Good luck
    HTH
    Rasika
    **** Pls rate all useful responses ****

  • Finding the right harddrive?

    Hi!
    I am trying to find the right HD to swap with my current 160GB. The criteria are simple. At least 500GB and 7200 RPM.
    However I don't know which are compatible. I have a 15" MacBookPro (ver. 2,2) 2,16 GHz Intel Core Duo 2 from January 2006, with 4 GB Ram installed. I wan't to make a clean install with Snow Leopard once the disk is up and running. But which to chose. It seems there are a lot of problems with the Seagate Momentus so I was looking at this one:
    http://www.edbpriser.dk/Product/Details.aspx?pid=667834
    Is that a good choice?

    hitachi? eeek!
    on your machine, the 7200rpm drive won't make much, if any difference, due to that mac only being SATA I. between the density of the 500gb disk & the bottleneck on the sata bus, the rpm difference isn't a factor...
    so don't worry about getting a 7200 drive. if you find one at a good price or something, then that's fine.
    I would go with a Western Digital or Seagate. haven't seen good luck with hitachi or toshiba drives in the past. but I've haven't had good luck with WD either & seagate has fallen considerably due to varying firmware issues across the board.
    any SATA I or II drive will work, but don't get one with the motion sensor built into the drive (all of them have shock protection of some sort) as these will cause problems with your mac & OS X usually as your mac already has a motion / fall sensor.

  • EarPod does  not work on the right side. What should I do?

    My grandma brought me an iphone5s that came with Apple EarPods And when I tried using it the right side EarPod does not work... What should I do?

    Settings > General > Accessibility > Mono Audio > OFF

  • What is the right stream for reading a styled text ?

    I'm trying to write a code for a text processing program..
    It has to have functions to save the document and reopen it...
    how ever I'm trying to find the right stream to deal with the styled text.
    I'll appretiate any help and would be greatful if some piece of code was attached as an example.

    There was a tutorial somewhere on how to write an rtf editor. It basiocally used a jeditorpane, filled it with rtf data and saved the files. RTF is plain text (7bit ascii), like html, but the code is harder to read and nearly impossible to edit manually.
    here is helloworld.rtf:{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2\fcharset238 Arial;}{\f3\froman Times New Roman;}{\f4\fswiss\fprq2 Arial;}}
    {\colortbl\red0\green0\blue0;}
    \deflang2057\pard\plain\f4\fs20 Hello, World!\plain\f3\fs20
    \par }of course, all this is done in the background and all you have to see is the word-like document on screen.
    dave.

  • How can I repare the rights for my iPhoto-Library

    Hello dear Apple Support Community,
    I have a bigger problem with my iPhoto-Library which I saved on a external drive while I had a MacBook (with iPhoto '09). Now I bought me a new MacBook Pro and wanted to open the iPhoto-Library on my new MacBook Pro. iPhoto opens an tells me to update the Library for the new version of iPhoto (iPhoto '11). During this update iPhoto says that a problem occured with one or more data and that it needs to be repare the rights. Afterwards iPhoto tells me that the reparation didn't work, that iPhoto couldn't repare the rights. Then it closes.
    I already tried to change the rights in the information window of the Library, but I had no possibility to change it?!
    Thanks
    mad_max_222

    Can you successfully open the library on the EHD?  if so create a new, empty library in your PIctures folder and use the paid version of  iPhoto Library Manager to merge the library on the EHD with the new library on your new MBP.  Set the iPLM preferences somewhat as follows with  any personal changes:
    OT

  • Find the right package

    Hello there.
    I run an office at Greece and I need to find the proper Skype package for me.
    Firstly, I need a Skype number (in Greek format - +*edited for privacy* so customers can call, I need a platform in order to have a voice welcome message and a forwarder in order when press 1 for example to forward the call to another phone number or Skype contact. Also, I need this: I want with this account or by creating accounts in the same subscription to give the functionality to 2-3 of my partners to make or receive calls at the same time from the same IP or different ip's. I don't know if I have to buy more phone numbers or not.
    I have found a subscription for unlimited landline calls for Greece at around 60 euros per year. Is all these functionality I need included in this package? If not, please suggest the proper package for me and also the annual cost
    Thank you in advance

    What's brute force about using java.util.Manifest?
    Steffen
    Stefan Baramov wrote:
    > Hello PDE Team:
    > I have tried to find the right API calls to modify the Export-Package
    > header of the MANIFEST.MF through the IModel API of the PDE. No luck
    > so far. The only thing I found was the
    > org.eclipse.pde.internal.core.ibundle.IBundle interface which happen
    > to be internal.
    > How can my plug-in modify the MANIFEST.MF and in particular
    > Export-Package through the nice IModel interface without using brute
    > force such as modifying the file itself .
    >
    > I would appreciate any hints or pointers.
    >
    > Thanks
    > Stefan

  • I am trying to setup kvm. Am I on the right track?

    I am trying to  set up kvm and am a bit confused (probably by old information)
    lscpu
    Virtualization: AMD-V
    L1d cache: 16K
    L1i cache: 64K
    L2 cache: 2048K
    L3 cache: 8192K
    NUMA node0 CPU(s): 0-5
    grep -E "(vmx|svm|0xc0f)" --color=always /proc/cpuinfo
    Worked
    zgrep CONFIG_KVM /proc/config.gz
    CONFIG_KVM_GUEST=y
    # CONFIG_KVM_DEBUG_FS is not set
    CONFIG_KVM_APIC_ARCHITECTURE=y
    CONFIG_KVM_MMIO=y
    CONFIG_KVM_ASYNC_PF=y
    CONFIG_KVM_VFIO=y
    CONFIG_KVM=m
    CONFIG_KVM_INTEL=m
    CONFIG_KVM_AMD=m
    CONFIG_KVM_MMU_AUDIT=y
    CONFIG_KVM_DEVICE_ASSIGNMENT=y
    zgrep CONFIG_VIRTIO /proc/config.gz
    CONFIG_VIRTIO_BLK=m
    CONFIG_VIRTIO_NET=m
    CONFIG_VIRTIO_CONSOLE=m
    CONFIG_VIRTIO=m
    CONFIG_VIRTIO_PCI=m
    CONFIG_VIRTIO_BALLOON=m
    CONFIG_VIRTIO_MMIO=m
    CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
    lsmod | grep kvm
    kvm_amd 59131 0
    kvm 413027 1 kvm_amd
    lsmod | grep virtio
    [virtio_pci 17389 0
    virtio_balloon 12997 0
    virtio_scsi 17714 0
    virtio_blk 17295 0
    virtio_net 26460 0
    virtio_ring 17342 5 virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_scsi
    virtio 13058 5 virtio_blk,virtio_net,virtio_pci,virtio_balloon,virtio_scsi
    scsi_mod 142915 4 libata,sd_mod,sr_mod,virtio_scsi
    Is there any thing else that needs to be set up before I install virt-manager
    Confused?
    thanks
    Dave
    Last edited by spottyrover (2014-09-10 04:08:08)

    1. tags around your raw output!1. [ code ] tags around your raw output! 1.
    Looks pretty now. Always wondered how that was done
    2. Did you deplete the usefulness of https://wiki.archlinux.org/index.php/KVM to its entirety?
    that is what I am trying to follow.
    Is there more modules needed?
    Did it work correctly?
    It lacks information on how to add modules.
    I got it  working the first time by following multiple how tos and in the end I do not know which bits I done was needed and which bits was not  and they did.
    By the way. You did not answer the question.
    Am I on the right track?
    After all I am in the newbie corner
    Dave
    Last edited by spottyrover (2014-09-10 04:28:24)

  • I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    I was trying to make a new screen recording using quicktimeplay, but when I watched the video after recording it all I could hear was me talking while the video was showing on the screen. How do I turn off that recording and turn the right one on? thanks

    Hi j2399123,
    It sounds like your screen recording is doing what it was designed to do, capture what is happening on your screen, with optional voice over with the microphone.
    Screen recording is for recording what you see on the screen, it is not a "video capture" option, like for capturing a movie with sound that is playing on your screen.
    For the QuickTime recording options, check out "Recording with QuickTime Player" in
    Mac Basics: QuickTime Player creates, plays, edits, and shares video and audio files
    http://support.apple.com/kb/ht4024
    And for screen recording specifically, there's
    QuickTime Player 10.x: Record your computer’s screen
    http://support.apple.com/kb/PH5882
    Thank you for thinking of Apple Support Communities for your support needs.
    Nubz

  • I have tried importing / exporting my playlist from itunes; dragging songs from itunes to my ipod icon in the right corner; nothing is working.  I want to put songs back on my ipod touch version 6.1.5 from itunes version 11.1.3.8; any one have any ideas

    This is very fustrating I have tried a few different things I have seen on-line and nothing is working.  My itunes is version 11.1.3.8 and my ipod touch is ios version 6.1.5.  Since last Christmas I have a playlist called Christmas songs and I would like to move the songs back onto my ipod.  Before I could drag the songs from under the songs list over to the right and a list including my ipod would show.  It still does but when I do it now the songs do not show up in my ipod.  I would appreciate any ideas to get this to work again.

    Verify you have the right boxex checked to sync
    iTunes: Syncing media content to iOS devices and iPod
    Try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Unsync all music and resync
    - Restore from backup. See:                                                
    iOS: How to back up                                                                
      - Restore to factory settings/new iOS device.            

Maybe you are looking for

  • Questions for FI workshop

    Hello folks, I want to know if you guys have a question bank to start conducting workshop and create Blueprint for GL,AP, AR process. Any help would be appreciated. Best Regards Shine

  • How To make Openoffice look nicer in xfce4??

    Hi I´ve been using openoffice2 for month in xfce4. it always looked nice. The same like in kde or gnome. But since couple of days it looks like crap. Like an old GTK1 application. I really don´t know what the cause for this was / is. Anyone an idea?

  • Video Editing: Speed up selection of a video, how?

    Hello All,So I need to take a long video file, speed up the boring bits in the middle and slow it back down when the interesting bit happens, I know that sounded dodgy. So how do I do this? I have never done anything like this before so software reco

  • Error in Seeding Translation Text

    Has anybody ever seen the following error when seeding the translation text? ORA-20001: WWV_FLOW_SEED_TRANSLATIONS.SEED_UPDATE_ERROR Following the error above, updating the translate file produces the following error: ORA-00600: internal error code,

  • Delting Objects from production system

    Hello All, I need to delete some of the Infoobjects,ODS and Infocubes from my Production system. for e.g: We have Inserted infoobject ZXX as data target,so it is available under infoprovider. For this,we have update rules ZYYY. In the Infoprovider ta